| name | ssh-doctor |
| description | 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
egrep -n /etc/ssh/sshd_config /etc/ssh/sshd_config.d/* 2>/dev/null ||