ssh-doctor
SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions.
What this skill does
# 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: ```bash ssh -o RequestTTY=no -o RemoteCommand=none HOST 'hostname; id -un' ``` ## Baseline ```bash 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 [email protected] 'hostname; id -un' ``` Use `BatchMode=yes` only when password fallback would hang or prompt. ## Config ```bash 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 user - restrictive `AllowUsers` / `AllowGroups` - `Match` block accidentally applying - tiny `MaxStartups` - tiny `LoginGraceTime` - `ListenAddress` missing target interface ## Logs ```bash sudo log show --last 30m --predicate 'process == "sshd" OR process == "launchd"' --style compact | tail -160 ``` Important Mac symptom: - client: `kex_exchange_identification: Connection closed by remote host` - server log: `Could not create new instance of inetd service: 67: Too many processes` - `launchctl print system/com.openssh.sshd`: high `copy count` - many `sshd-session: USER` processes parented by PID 1 This means launchd accepted TCP but refused to spawn more sshd inetd copies. ## Stale sshd-session Fix Inspect first: ```bash 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: ```bash 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`. ## Firewall Only after loopback works but remote fails: ```bash 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: ```bash ifconfig | awk '/^[a-z0-9]+:/{iface=$1; sub(":","",iface)} iface ~ /^en[0-9]+$/ && /inet / {print iface, $2}' sudo lsof -nP -iTCP:22 -sTCP:LISTEN ``` ## OP Profile Block If asked to ensure `~/.profile` has a Codex-managed `OP_SERVICE_ACCOUNT_TOKEN` copied from another host: - verify exact variable/markers without printing value - copy only the matching line/block - redirect through a `chmod 600` temp file - never echo the token Presence check: ```bash 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: ```bash 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" ``` ## Closeout Report: - root cause - exact commands changed - validation output, redacted as needed - whether remote should retry
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.