ssh-mcp
README.md
# ssh-mcp
A small local [MCP](https://modelcontextprotocol.io) server that lets Claude (desktop app)
run commands on **network devices and servers over SSH**, using [Paramiko](https://www.paramiko.org/).
Companion to [switch-console-mcp](https://github.com/Johnwin78-ctrl/switch-console-mcp) (serial console).
## Tools
| Tool | What it does |
|---|---|
| `ssh_list_targets` | Lists configured targets (name, host, port, mode). Never returns credentials. |
| `ssh_test` | Checks that a target is reachable and the login works. |
| `ssh_run` | Runs a list of commands on a target and returns the output. |
### Modes (per target)
- **`shell`** – interactive CLI for switches, routers, firewalls. All commands run in one
session, so `enable` → `configure terminal` → interface commands work in order.
`--More--` style paging is answered automatically.
- **`exec`** – one command per channel for Linux / Windows OpenSSH. Returns stdout,
stderr and exit code for each command.
## Requirements
- Python 3.10+
- Claude desktop app
```
pip install -r requirements.txt
```
Works with both `mcp` 1.x (`FastMCP`) and 2.x (`MCPServer`).
## Setup
1. Copy `ssh_mcp.py` to the machine that can reach your devices.
2. Copy `ssh_targets.example.json` to `ssh_targets.json` and fill in your devices
(`password` or `key_file`, optional `key_passphrase`, `mode`).
3. Add the server to your Claude desktop config
(Windows: `%APPDATA%\Claude\claude_desktop_config.json`) inside `"mcpServers"` —
see `claude_desktop_config.ssh.example.json`.
4. Fully restart the Claude desktop app.
### Environment variables
| Variable | Default | Meaning |
|---|---|---|
| `SSH_TARGETS_FILE` | `ssh_targets.json` next to the script | Targets file |
| `SSH_STRICT_HOST_KEYS` | `false` | `true` = reject hosts not in `known_hosts` |
| `SSH_LOG` | `ssh_mcp_log.txt` next to the script | Output log |
## Example
Ask Claude: *"On lab-switch, show the interface status."*
Claude calls `ssh_run` with `target="lab-switch"` and `commands=["show interfaces status"]`.
## Security notes
- Credentials live only in `ssh_targets.json` on your machine (it is in `.gitignore`).
Claude sees target names and command output, never passwords.
- With `SSH_STRICT_HOST_KEYS=false` unknown host keys are auto-accepted — fine for a lab,
not for production. Set it to `true` once your hosts are in `known_hosts`.
- `ssh_run` gives Claude full CLI access to every configured target. Only add devices you
are comfortable having Claude change, and prefer least-privilege accounts.
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues