Guide · Agent skill
How to use the SSH Doctor agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
SSH Doctor is an agent skill: a written troubleshooting playbook that an AI agent reads and follows when SSH into a Mac fails. It is aimed at Mac users, sysadmins and engineers who run an agent such as Claude Code against their own machines. After this guide you will know what the skill does, how to install it, how to ask for it in plain language, and which safety checks to apply before letting it run commands.
Quick start
- 1Download the ZIP. Download the ssh-doctor ZIP from this page. It contains SKILL.md.
- 2Unzip into a skills folder. Place the ssh-doctor folder in ~/.claude/skills/ for personal use, or in a project's .claude/skills/ folder for one project.
- 3Or upload in the Claude apps. Go to Settings → Capabilities → Skills and upload the skill if you use the Claude apps.
- 4Confirm requirements. Check that the Mac has sudo access and an OpenSSH server (sshd) on the target machine.
- 5Describe the symptom. Ask in plain language, for example that SSH connects then closes before login, and name the Mac involved.
- 6Review commands before approval. Read each sudo, kill, restart or file-edit command the agent proposes before allowing it to run.
- 7Save the closeout report. Keep the root cause, changed commands and validation output for your records.
What is an agent skill, and what does SSH Doctor make the agent do?
An agent skill is a folder containing a SKILL.md file with instructions the AI agent loads when a task matches the skill's description. SSH Doctor's description is "SSH triage: Remote Login, launchd sshd, pre-auth closes, stale sessions."
The skill is for macOS machines where SSH connects but then closes before authentication, or where Remote Login appears enabled but does not work. Once loaded, the agent follows a fixed order: it validates locally first, using loopback (127.0.0.1) to tell server-side problems from network problems. It then reads the sshd configuration and system logs, looks for stuck sshd-session processes, and only checks the firewall and packet filter if loopback works but remote login fails.
The skill can also restart the SSH service and, when stranded sessions clearly block new logins, terminate them. It includes a procedure for copying a 1Password service account token line into a user's ~/.profile on a Mac.
Install SSH Doctor: download the ZIP and unzip it into a skills folder
Download the ssh-doctor ZIP from this page and unzip it. The package contains SKILL.md. For a personal setup, place the ssh-doctor folder in ~/.claude/skills/. For a single project, place it in that project's .claude/skills/ folder instead, so it applies only there.
If you use the Claude apps rather than a local folder, you can upload the skill under Settings → Capabilities → Skills.
- Personal install: ~/.claude/skills/ssh-doctor/
- Project install: .claude/skills/ssh-doctor/ inside your project
- Claude apps: Settings → Capabilities → Skills
Check that the skill is ready before you rely on it
Confirm the requirements first. You need macOS with sudo access and an OpenSSH server (sshd) running on the target Mac. The commands use standard macOS tools: launchctl, systemsetup, lsof, socketfilterfw, pfctl and log.
The skill runs scripts and uses the network, so review what it will execute before you approve it. Its baseline checks begin with a non-interactive SSH test that you can also run yourself, which uses RequestTTY=no and RemoteCommand=none so no shell or command is started on the remote side beyond the test.
ssh -o RequestTTY=no -o RemoteCommand=none HOST 'hostname; id -un'Trigger the skill with a natural request
You do not need to type the skill name. The agent matches your request against the skill's description, so describe the symptom. The source says the skill applies when SSH connects then closes before auth, when Remote Login seems advertised but unusable, or when local or remote Mac SSH needs diagnosis.
Give the agent the context it needs: which Mac, whether you are working locally or remotely, and what you already tried. Naming the symptom in the client's words helps, such as "connection closed by remote host" during key exchange.
- "My Mac's SSH server accepts connections but drops them before login. Use SSH Doctor to diagnose it."
- "Remote Login shows as on in System Settings but I can't connect from my laptop. Check it."
- "Diagnose SSH on this Mac: is it a server problem or a firewall problem?"
What the agent checks and in what order
The skill's rules tell the agent to report suspicious configuration lines before changing /etc/ssh/sshd_config, and not to print secrets, tokens or full environment output. A loopback failure points to sshd, launchd or config on the server. Loopback success with remote failure points to the network, firewall, filter or listen path.
A key symptom the skill describes is a client message of kex_exchange_identification: Connection closed by remote host, paired with a server log line reading "Could not create new instance of inetd service: 67: Too many processes", a high copy count in launchctl output, and many sshd-session: USER processes parented by PID 1. The skill reads this as launchd accepting TCP connections but refusing to spawn more sshd copies.
- Baseline: system info, Remote Login status, launchd state of com.openssh.sshd, listening port 22, and a loopback login test
- Config: effective sshd settings and any AllowUsers, DenyUsers, Match, MaxStartups or LoginGraceTime lines
- Logs: sshd and launchd entries from the last 30 minutes
- Stale sessions: inspect sshd-session processes before terminating anything
- Firewall: socketfilterfw, pfctl and listening interface, only after loopback works
sudo systemsetup -getremoteloginExample: clearing stale sshd-session processes
When the launchd copy count is high and many sshd-session processes are parented by PID 1, the skill first inspects them and lists their state and elapsed time without changing anything. Only if the sessions are clearly stranded and blocking new SSH does it send a TERM signal to matching processes, wait two seconds, and list again. If TERM leaves blockers, the skill says to re-check ownership and active shells before using KILL.
Read the inspection output yourself before approving the termination step. Ending a session someone is actively using is the main risk here.
ps -axo pid=,args= | awk '/sshd-session: / && !/awk/ {print $1}' | xargs sudo kill -TERMSafety notes: sudo, scripts, network and secrets
SSH Doctor uses sudo, can kill processes, can restart the SSH service, and can edit system files. Read every command before it runs, especially anything touching /etc/ssh/sshd_config, launchd, or running sessions. The skill itself does not say it will make a backup before editing configuration, so do not assume one exists.
The token section moves a secret between hosts. It asks the agent to verify markers without printing the value, copy only the matching line through a chmod 600 temporary file, and never echo the token. Do not use that section with shared or production credentials unless someone has reviewed the exact commands. Remove the temporary file if a step fails.
- Read each command before approving it
- Avoid the token-copy section for shared or production credentials without review
- Expect the skill to use sudo and the network
Tips for getting useful results
Ask the agent to report its findings before it makes changes. The skill's closeout asks for the root cause, the exact commands changed, validation output (redacted as needed), and whether the remote should retry. Keep that report; it is your record of what changed.
Run the checks on the machine that has the problem, and compare loopback with remote results. That comparison is what separates a server fault from a network or firewall fault.
- Ask for a root-cause report before any change is made
- Keep the closeout report for your records
- If you manage several Macs, run the same baseline on each so the results are comparable
What people use it for
- Diagnosing a Mac whose SSH server accepts TCP connections but closes them during key exchange.
- Checking whether Remote Login is actually working after it shows as enabled in System Settings.
- Finding out whether a failure is on the server (sshd, launchd, config) or on the path (network, firewall, packet filter).
- Clearing stranded sshd-session processes that block new logins, after reviewing them first.
- Reviewing sshd configuration for AllowUsers, DenyUsers, MaxStartups or LoginGraceTime problems before changing anything.
Frequently asked questions
How do I install the SSH Doctor agent skill?
Download the ssh-doctor ZIP from this page and unzip it. Put the ssh-doctor folder in ~/.claude/skills/ for personal use, or in a project's .claude/skills/ folder for one project. In the Claude apps, you can instead upload it under Settings → Capabilities → Skills.
What do I need to run SSH Doctor?
You need macOS with sudo access and an OpenSSH server (sshd) on the target Mac. The commands rely on standard macOS tools including launchctl, systemsetup, lsof, socketfilterfw, pfctl and log. The skill is not written for Linux or other non-macOS systems.
Is SSH Doctor free?
The source material provided here does not state pricing or licence terms beyond the listed licence, which is MIT. Check the repository's licence file for the exact terms before you redistribute it.
Can SSH Doctor run on Linux servers?
Not as written. The commands use macOS-specific tools such as systemsetup, launchctl and socketfilterfw. The diagnostic approach could be adapted, but the agent would need to be changed to use the equivalent Linux commands.
Is it safe to let the agent kill processes and edit SSH config?
It can be, if you review each command first. The skill can use sudo, terminate sshd-session processes, restart the SSH service and edit system files. It asks the agent to report suspicious config lines before changing /etc/ssh/sshd_config, and to inspect stale sessions before terminating them.
What should I do if the agent reports that SSH connects then closes before authentication?
Ask the agent to validate loopback first. If the loopback login fails, the problem is on the server side, such as sshd, launchd or config. If loopback works but remote login fails, the skill directs the agent to check the firewall, packet filter and listening interface.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
SSH Doctor suits Mac users, sysadmins and engineers who already run an AI agent against their own macOS machines and need a repeatable way to diagnose Remote Login failures. It is a poor fit for Linux servers, for anyone who cannot review shell commands before they run, or for handling shared or production credentials without review. If your problem is on a non-macOS system, use a Linux-oriented troubleshooting guide instead.
Download the skill