بنقرة واحدة
ssh-doctor
SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Delegated maintainer ops: decision-ready PRs, worker monitoring, queue cleanup, releases.
ClawSweeper status: URLs, workflow health, active workers, ops snapshot.
macOS app release: Sparkle, notarization, GitHub Release, Homebrew, closeout.
GitHub PR/issue agent transcripts: redact, preview, and insert safely.
GitHub issue/PR triage: queues, CI, blockers, risk, proof, next actions.
Codex/OpenClaw skill audit: live budget, usage, duplicates, compact descriptions.
| name | ssh-doctor |
| description | SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions. |
Use when SSH connects then closes before auth, Remote Login seems advertised but unusable, or local/remote Mac SSH needs diagnosis.
/etc/ssh/sshd_config.ssh -o RequestTTY=no -o RemoteCommand=none HOST 'hostname; id -un'
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.
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:
DenyUsers matching target userAllowUsers / AllowGroupsMatch block accidentally applyingMaxStartupsLoginGraceTimeListenAddress missing target interfacesudo log show --last 30m --predicate 'process == "sshd" OR process == "launchd"' --style compact | tail -160
Important Mac symptom:
kex_exchange_identification: Connection closed by remote hostCould not create new instance of inetd service: 67: Too many processeslaunchctl print system/com.openssh.sshd: high copy countsshd-session: USER processes parented by PID 1This means launchd accepted TCP but refused to spawn more sshd inetd copies.
Inspect first:
sudo launchctl print system/com.openssh.sshd 2>&1 | egrep 'active count|copy count|state =|last exit code|runs ='
ps -axo pid,ppid,uid,user,state,lstart,etime,comm,args | awk '/sshd-session:/ && !/awk/ {print}'
sudo lsof -nP -c sshd-session -iTCP 2>/dev/null | head -120
If stale sessions are clearly stranded and blocking new SSH, terminate by selected command-line match:
ps -axo pid=,args= | awk '/sshd-session: / && !/awk/ {print $1}' | xargs sudo kill -TERM
sleep 2
ps -axo pid=,args= | awk '/sshd-session: / && !/awk/ {print}'
If TERM leaves blockers, re-check ownership and active shells before using KILL.
Only after loopback works but remote fails:
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps | grep -i ssh -A2 -B2 || true
sudo pfctl -sr 2>/dev/null | head -80
sudo pfctl -si 2>/dev/null | head -80
Also check listen address and target interface:
ifconfig | awk '/^[a-z0-9]+:/{iface=$1; sub(":","",iface)} iface ~ /^en[0-9]+$/ && /inet / {print iface, $2}'
sudo lsof -nP -iTCP:22 -sTCP:LISTEN
If asked to ensure ~/.profile has a Codex-managed OP_SERVICE_ACCOUNT_TOKEN copied from another host:
chmod 600 temp filePresence check:
awk 'BEGIN{b=0;e=0;x=0} /BEGIN Codex-managed OP_SERVICE_ACCOUNT_TOKEN/ {b=1} /END Codex-managed OP_SERVICE_ACCOUNT_TOKEN/ {e=1} /^[[:space:]]*(export[[:space:]]+)?OP_SERVICE_ACCOUNT_TOKEN=/ {x=1} END{print "marker_begin", b; print "marker_end", e; print "exact_var", x}' ~/.profile
Append from remote host:
tmpfile=$(mktemp /tmp/codex-op-token.XXXXXX)
chmod 600 "$tmpfile"
ssh -o RequestTTY=no -o RemoteCommand=none HOST 'awk '\''/^[[:space:]]*(export[[:space:]]+)?OP_SERVICE_ACCOUNT_TOKEN=/ {print; exit}'\'' ~/.profile' > "$tmpfile"
if [ -s "$tmpfile" ]; then
{
printf '\n# BEGIN Codex-managed OP_SERVICE_ACCOUNT_TOKEN\n'
sed -n '1p' "$tmpfile"
printf '# END Codex-managed OP_SERVICE_ACCOUNT_TOKEN\n'
} >> ~/.profile
fi
rm -f "$tmpfile"
Report: