An MCP (Model Context Protocol) server that gives AI assistants secure, scoped SSH access to one or more remote servers.
ssh-mcp runs over stdio and works with any MCP-compatible client:
Claude Desktop, Claude Code, Cursor, Devin, VS Code, and Cline. It
exposes eight tools for command execution, SFTP file transfer, directory
sync, port forwarding, and remote system status collection.
AI assistants that need to operate on remote servers typically either
get a raw shell (unsafe, unscoped) or have no SSH access at all.
ssh-mcp sits in between: it gives the agent a small, auditable set of
tools, each gated by an optional command whitelist/blacklist and path
restrictions, so the operator controls exactly what the agent can do.
- Command policy –
whitelistandblacklistregex patterns gate every command before execution. Without a whitelist, all commands are allowed and a warning is logged at startup. - Path restrictions –
allowed_local_pathsandallowed_remote_pathsconfine SFTP transfers to specific directories and reject path traversal. - Secrets via env vars – password, passphrase, and 2FA code are passed via environment variables, never on the command line.
- Hot-reload – when started with
--config, the config file is watched for changes and reloaded without restarting the server. Add, remove, or modify servers and the change takes effect within seconds.
| Tool | Description |
|---|---|
execute-command |
Run a command on a remote server |
upload |
Upload a local file via SFTP |
download |
Download a remote file via SFTP |
list-remote |
List a remote directory via SFTP |
dir-sync |
Recursively sync a directory between local and remote |
port-forward |
Open, close, and list local/remote port forwards |
server-status |
Collect system status (CPU, memory, disk, GPU, services) |
list-servers |
List configured servers and their connection status |
See Tools for arguments and examples.
- The AI client sends an MCP
tools/callrequest over thessh-mcpprocess's stdin. ssh-mcpresolves the target connection (defaulting to the first configured server).- The command or transfer is validated against the server's command policy and allowed paths.
- The operation runs over SSH/SFTP (or opens a port forward) with the configured timeout and output cap.
- A structured result returns to the client. Errors carry a stable
ssh.ToolErrorcode and aRetriableflag so the agent can decide whether to retry.
See Architecture for the package layout, dependency graph, and full request data flow.
git clone https://github.com/overklassniy/ssh-mcp.git
cd ssh-mcp
make buildCreate a minimal ssh-mcp.toml:
[[server]]
name = "web"
host = "example.com"
username = "deploy"
port = 22
private_key = "~/.ssh/id_ed25519"Register it in your client:
ssh-mcp install --client claude-code --config ./ssh-mcp.tomlRestart your AI client, then ask the agent:
Use the list-servers tool.
You should see your server with a connected or disconnected status.
Three install paths produce the same result – an MCP server entry in your client's config file. See Installation for the full guide.
-
Local binary –
make build, thenssh-mcp install --client <client> --config ./ssh-mcp.toml. Supported clients:claude-desktop,claude-code,cursor,Devin,vscode,cline. -
Docker –
ssh-mcp install --client <client> --docker --config ./ssh-mcp.toml. Defaults toghcr.io/overklassniy/ssh-mcp:latest. -
MCPB one-click bundle – download the
.mcpbbundle from the Releases page and open it in a client that supports MCPB (Claude Desktop, Claude Code, MCP for Windows). -
Paste-in config – skip the installer and paste a ready-made server entry directly into your client's config. The
snippetsubcommand generates it for your exact setup:ssh-mcp snippet --docker --host 192.168.1.1 --user root ssh-mcp snippet --gorun --host 192.168.1.1 --user root
Docker uses the published multi-arch image;
--gorunusesgo run github.com/overklassniy/ssh-mcp/cmd/ssh-mcp@latest(the Go-native equivalent ofnpx -y <package>, requires the Go toolchain). Secrets stay in theenvblock, never inargs. See Installation for ready-to-paste JSON blocks.
Single-server mode skips the TOML file and takes connection details as CLI flags:
ssh-mcp --host example.com --user deploy --port 22 \
--private-key ~/.ssh/id_ed25519If you have the Go toolchain (Go 1.26+) installed, you can skip the
binary build entirely. Add this entry to your client's mcpServers
config (e.g. ~/.codeium/Devin/mcp_config.json):
{
"mcpServers": {
"ssh-mcp": {
"command": "go",
"args": [
"run",
"github.com/overklassniy/ssh-mcp/cmd/ssh-mcp@latest",
"--host", "192.168.1.1",
"--port", "22",
"--user", "root",
"--transport", "exec"
],
"env": {
"SSH_MCP_PASSWORD": "your-password"
}
}
}
}On first run, go run fetches and compiles the latest tagged release,
then starts the stdio MCP server. Subsequent runs use the build cache.
For private-key auth, replace SSH_MCP_PASSWORD with
SSH_MCP_PASSPHRASE and add --private-key to args. Pin a specific
version by replacing @latest with @v1.0.0.
ssh-mcp is configured with a TOML file: a top-level [defaults]
section and one or more [[server]] entries. Each server inherits from
[defaults], then from built-in defaults, and is validated at startup.
[defaults]
command_timeout = "30s"
connection_timeout = "30s"
sftp_timeout = "5m"
keepalive_interval = "10s"
keepalive_count_max = 3
max_output_bytes = 10485760
transport = "exec"
[[server]]
name = "web"
host = "web.example.com"
username = "deploy"
port = 22
private_key = "~/.ssh/id_ed25519"
whitelist = ["^systemctl status .*", "^journalctl .*", "^ls .*"]
allowed_remote_paths = ["/var/log", "/srv"]
allowed_local_paths = ["~/downloads"]See Configuration for the full reference: auth methods, command policy, path restrictions, keepalive, transport modes, and validation rules.
ssh-mcp does not verify remote host keys (InsecureIgnoreHostKey).
Security is enforced through two operator-configured mechanisms:
- Command policy –
whitelist/blacklistregex patterns gate every command, including the individual probe commands used byserver-status, so a restrictive whitelist cannot be bypassed. - Path restrictions –
allowed_local_pathsandallowed_remote_pathsconfine SFTP operations; remote paths must be absolute POSIX paths.
Sensitive values are injected via environment variables:
| Env var | Used for |
|---|---|
SSH_MCP_PASSWORD |
Password auth |
SSH_MCP_PASSPHRASE |
Private key passphrase |
SSH_MCP_2FA_CODE |
2FA code for keyboard-interactive auth |
- Clients – Claude Desktop, Claude Code, Cursor, Devin, VS Code, Cline.
- Platforms – Windows, macOS, Linux (
amd64,arm64). - Runtime – Go 1.26+ to build, or a prebuilt binary from the Releases page.
- Installation – local binary, Docker, and MCPB one-click bundles.
- Configuration – full TOML reference.
- Tools – the eight MCP tools, arguments, and examples.
- Architecture – package layout and request data flow.
- Troubleshooting – common issues and fixes.
The same pages are mirrored to the repository's GitHub Wiki by the
wiki-sync workflow; edit them in docs/, not in the wiki UI.
This project was inspired by classfang/ssh-mcp-server.
MIT. See LICENSE for the full text. The project also declares
MIT in mcpb/manifest.json.
