Ssh Doctor
SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions.
Install
npx skills add steipete/agent-scripts --skill ssh-doctor -g -a claude-code -y- Repository
- steipete/agent-scripts7.4k
- Category
- Engineering
- Updated
- 5d ago
- License
- MIT
- Context cost
- Lightabout 1,192 tokens
- Runs scripts
- No, instructions only
What it does
SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions.
SSH Doctor
Use when SSH connects then closes before auth, Remote Login seems advertised but unusable, or local/remote Mac SSH needs diagnosis.
Rules
- Do not print secrets, tokens, full env, or broad secret grep output.
- Validate locally first: loopback failure means server-side sshd/launchd/config; loopback success plus remote failure means network/firewall/filter/listen path.
- Report suspicious config lines before changing
/etc/ssh/sshd_config. - Prefer non-interactive SSH:
ssh -o RequestTTY=no -o RemoteCommand=none HOST 'hostname; id -un'
Baseline
hostname; id -un; sw_vers
ipconfig getifaddr en0
ipconfig getifaddr en1 2>/dev/null || true
ipconfig getifaddr en7 2>/dev/null || true
sudo systemsetup -getremotelogin
sudo systemsetup -setremotelogin on
sudo launchctl print system/com.openssh.sshd 2>&1 | head -80
sudo launchctl kickstart -k system/com.openssh.sshd
sudo lsof -nP -iTCP:22 -sTCP:LISTEN
nc -vz 127.0.0.1 22
ssh -4 -F /dev/null -o RequestTTY=no -o RemoteCommand=none USER@127.0.0.1 'hostname; id -un'
Use BatchMode=yes only when password fallback would hang or prompt.
Config
sudo sshd -T 2>&1 | egrep -i '^(allowusers|denyusers|allowgroups|denygroups|listenaddress|maxstartups|logingracetime|usepam|passwordauthentication|pubkeyauthentication|authenticationmethods)'
sudo egrep -n '^[[:space:]]*(AllowUsers|DenyUsers|AllowGroups|DenyGroups|Match|MaxStartups|LoginGraceTime|ListenAddress|AuthenticationMethods|UsePAM|PasswordAuthentication|PubkeyAuthentication)\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/* 2>/dev/null || true
Suspicious:
DenyUsersmatching target user- restrictive
AllowUsers/AllowGroups Matchblock accidentally applying- tiny
MaxStartups - tiny
LoginGraceTime ListenAddressmissing target interface
Logs
sudo log show --last 30m --predicate 'process == "sshd" OR process == "launchd"' --style compact | tail -160
Important Mac symptom:
