ssh MCP server
Commit Nov 9, 2026Provides AI agents with persistent SSH sessions, virtual terminal emulation, and SFTP file transfers via the Model Context Protocol.
Also known as taigrr/ssh-mcp
- Stars
- 13
- Tools
- 15
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 9, 2026
- License
- 0BSD
What is ssh MCP?
ssh provides AI agents with persistent SSH sessions, virtual terminal emulation, and SFTP file transfers via the Model Context Protocol. It exposes 15 tools, such as ssh_connect, ssh_exec, ssh_send_command.
Summary generated from the project's README
About ssh MCP server
Managing remote servers and debugging infrastructure from within an AI coding agent is what ssh-mcp enables. This server provides AI agents with direct access to a specific set of remote hosts, allowing them to execute commands, manage files, and interact with terminal user interfaces. It works by resolving connection details from your existing ~/.ssh/config and authenticating through ssh-agent or gpg-agent, ensuring it uses your established security workflows.
Developers use this tool to bridge the gap between local coding and remote execution. It features a virtual terminal with PTY emulation to handle ANSI rendering, making it possible for an agent to see exactly what a human would see in a terminal. The server supports bidirectional file transfers via SFTP, including recursive directory uploads and downloads. To maintain security, it operates on an allowlist-only basis, requiring you to explicitly define permitted hosts via the --allowed-hosts flag or a config.json file.
What you can do with it
- 1Remote server debuggingAn AI agent can connect to a staging server to investigate logs or system status using a persistent shell.
- 2Automated file managementYou can instruct an agent to move configuration files or deploy code to a remote machine using SFTP.
Written from the project's README. Every use case is checked against a quote from it.
ssh MCP tools 15
Detected from the READMEssh_connectssh_execssh_send_commandssh_send_keysssh_get_screenssh_clear_screenssh_resizessh_read_filessh_write_filessh_edit_filessh_uploadssh_download
| ssh_connect | — | |
| ssh_exec | — | |
| ssh_send_command | — | |
| ssh_send_keys | — | |
| ssh_get_screen | — | |
| ssh_clear_screen | — | |
| ssh_resize | — | |
| ssh_read_file | — | |
| ssh_write_file | — | |
| ssh_edit_file | — | |
| ssh_upload | — | |
| ssh_download | — |
Show all 15 toolsShow fewer tools
ssh_list_sessionsssh_list_hostsssh_close_session
| ssh_list_sessions | — | |
| ssh_list_hosts | — | |
| ssh_close_session | — |
Configuration
SSH_AUTH_SOCK
| Name | Description | |
|---|---|---|
| SSH_AUTH_SOCK | — |
Automated checks
Ran Nov 13, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachabletaigrr/ssh-mcp is public and reachablegithub.com/taigrr/ssh-mcp ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)Not checked
- Open source license (OSI)0BSDspdx.org/licenses/0BSD.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-09github.com/taigrr/ssh-mcp ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNot checked
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model15 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNo tool named like delete, drop or execPass
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubssh-mcp
MCP server providing persistent SSH sessions for AI coding agents via the Model Context Protocol.
The Problem
AI coding agents can't interact with remote machines. You need to manually SSH in, run commands, and paste output back. For fleet management, server debugging, or remote development, this kills the feedback loop.
The Solution
ssh-mcp gives your AI agent direct SSH access to an allowed set of hosts. It resolves connections from ~/.ssh/config, authenticates via ssh-agent/gpg-agent, and exposes a virtual terminal so the agent sees exactly what you'd see.
# Start with allowed hosts
ssh-mcp --allowed-hosts="web1,db1,staging"
Features
- SSH config integration — Resolves hosts from
~/.ssh/config(HostName, Port, User, IdentityFile) - Agent forwarding — Authenticates via
ssh-agentorgpg-agent(SSH_AUTH_SOCK) - Virtual terminal — Full PTY emulation with ANSI rendering via charmbracelet/x/vt
- File transfer — Bidirectional file and directory transfers via SFTP (recursive)
- Allowlist-only access — Only explicitly permitted hosts can be connected to
- Session management — Multiple concurrent sessions with independent state
- Zero config — Works out of the box if your
~/.ssh/configis set up
Installation
go install github.com/taigrr/ssh-mcp@latest
Requirements
- Go >= 1.26.5 (for installation)
~/.ssh/configentries for your hosts- One of:
ssh-agentorgpg-agentrunning (recommended)- SSH private key at
~/.ssh/id_ed25519or~/.ssh/id_rsa
Quick Start
- Ensure your hosts are in
~/.ssh/config:
Host my-desktop
HostName 10.0.1.50
User tai
- Run with allowed hosts:
ssh-mcp --allowed-hosts="my-desktop"
- Or use a config file (
config.jsonin working directory):
{
"hosts": ["my-desktop", "web1", "db1"]
}
🔌 MCP Tools
| Tool | Description |
|---|---|
ssh_connect |
Connect to an allowed host by alias (optional width, height) |
ssh_exec |
Run a command and block until it finishes or times out |
ssh_send_command |
Send a command (non-blocking); for TUIs / fire-and-forget |
ssh_send_keys |
Send raw bytes with no newline (Ctrl-C, Esc, arrows, TUI keys) |
ssh_get_screen |
Get the current terminal screen content |
ssh_clear_screen |
Reset the local emulator screen + scrollback |
ssh_resize |
Resize a session's terminal (sends SIGWINCH to the remote shell) |
ssh_read_file |
Read a remote file over SFTP (clean bytes, no shell) |
ssh_write_file |
Write a remote file over SFTP (no quoting pitfalls) |
ssh_edit_file |
Exact find-and-replace edit of a remote file (read it first) |
ssh_upload |
Upload a local file or directory via SFTP |
ssh_download |
Download a remote file or directory via SFTP |
ssh_list_sessions |
List all sessions with active state and size |
ssh_list_hosts |
List allowed hosts with resolved connection details |
ssh_close_session |
Close a session |
Choosing between ssh_exec and ssh_send_command
Both run in the same persistent shell (cwd and environment carry over), but they have opposite blocking semantics:
ssh_execis what you want for almost everything that should finish: builds,git, installs, queries, scripts. It wraps the command with internal sentinels, blocks until it completes ortimeout_mselapses, and returns clean output (ANSI/prompt stripped) plus the exit code. On timeout the command is not killed — it keeps running, and you get a screen snapshot so you can see what it is stuck on, then poll (ssh_get_screen), interrupt (ssh_send_keysCtrl-C), or wait longer.ssh_send_commandis non-blocking and exists for interactive TUIs (vim, less, htop, tmux, REPLs) and fire-and-forget launches. It returns the screen after a short settle delay regardless of completion.
The emulator backing every session is a real virtual terminal, so even when an
ssh_exec command times out or a TUI is open, the session stays responsive and
its state is always inspectable via ssh_get_screen — nothing can hang the
server.
ssh_exec's timeout_ms defaults to 60s (matching Crush's bash tool, which
auto-backgrounds a synchronous command after 60s) and is capped at 10m. A
timeout is not an error: the tool returns a normal result noting the command
is still running, plus the current screen, so the model just keeps going with
ssh_get_screen / ssh_send_keys.
One shell per session: concurrency
Each session is a single interactive shell with one stdin and one stdout. The server keeps that consistent under concurrent tool calls:
- Byte level — all writes to the shell go through one serialized path, so bytes from different calls never interleave mid-sequence. Output is captured by a concurrency-safe terminal emulator.
- Two
ssh_execat once (same session) — rejected. Only onessh_execmay be waiting in a session's shell at a time; the loser gets an "already executing" error. This prevents two wrapped commands from racing into the same shell and scrambling each other's captured output. ssh_send_commandduring anssh_exec— rejected for the same reason (it would inject a second command line mid-exec).ssh_send_keysduring anssh_exec— allowed on purpose. This is how you send Ctrl-C to interrupt a command that timed out and is still running.- Different sessions — fully independent; run them in parallel freely.
If you fire several commands at the same session simultaneously, expect all but one to come back with an "already executing" error rather than corrupting the shell. Sequence them, or use separate sessions.
Terminal size
Sessions default to a 200x50 virtual terminal, large enough for typical
ls, tail, ps, log, and progress-bar output without triggering line wraps
that pollute scrollback. Clients can override the initial size via width /
height on ssh_connect, or resize a live session with ssh_resize. Values
are clamped to [20, 500] columns x [5, 200] rows.
Session lifecycle
ssh_list_sessions returns every session the server knows about along with
its current state ([active] or [inactive]) and current terminal size.
Background goroutines watch each session's stdout and keepalive channel; when
they detect that the remote end has gone away (EOF, keepalive timeout) the
session is automatically marked inactive and removed from the manager, so
a follow-up ssh_list_sessions won't keep advertising a dead entry. Only
sessions reported as [active] accept ssh_send_command / ssh_get_screen
/ ssh_resize; attempts on inactive entries return ErrSessionInactive.
ssh_send_command is non-blocking
ssh_send_command writes the command + newline to the remote shell's stdin,
waits a short settle delay (~3.5s) for the terminal to redraw, then returns
the screen as-is. It does not wait for the command to finish. This is
intentional: it keeps TUIs (vim, htop, tmux, less) interactive across calls.
Practical consequences for clients (especially LLM agents):
- A long-running command (
sleep 60,make, training jobs, package installs) keeps running on the remote host after the call returns. - To wait for completion, sleep on your side (your own timer / bash tool
outside this MCP), then call
ssh_get_screento read fresh output. Do not prefixsleep N;to the SSH command expecting it to block here. - Sending a second command before the first finishes queues bytes in the
remote shell's stdin and produces garbled, interleaved output. Poll with
ssh_get_screenuntil you see the prompt first. - For output you'd rather not stream through the screen, redirect to a file
(
cmd > /tmp/out 2>&1 &) and read it back withcat.
⚙️ Crush Configuration
Add to your project's crush.json or .crush.json:
{
"mcp": {
"ssh": {
"command": "ssh-mcp",
"args": ["--allowed-hosts=my-desktop,staging"],
"type": "stdio"
}
}
}
🤖 Claude Configuration
Claude Code
Register the server with the Claude Code CLI (writes to your MCP config):
claude mcp add ssh -- ssh-mcp --allowed-hosts=my-desktop,staging
Or add it manually to ~/.claude.json (global) or .mcp.json (project):
{
"mcpServers": {
"ssh": {
"command": "ssh-mcp",
"args": ["--allowed-hosts=my-desktop,staging"],
"type": "stdio"
}
}
}
Claude Desktop
Add to your claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ssh": {
"command": "ssh-mcp",
"args": ["--allowed-hosts=my-desktop,staging"]
}
}
}
If ssh-mcp is not on your PATH, use the absolute path (e.g. the output of which ssh-mcp, typically ~/go/bin/ssh-mcp) as the command. Because the server authenticates via ssh-agent, ensure SSH_AUTH_SOCK is available to the Claude process; you can pass it explicitly:
{
"mcpServers": {
"ssh": {
"command": "/Users/you/go/bin/ssh-mcp",
"args": ["--allowed-hosts=my-desktop,staging"],
"env": {
"SSH_AUTH_SOCK": "/path/to/ssh-agent.sock"
}
}
}
}
Restart Claude Desktop after editing the config.
Flags
| Flag | Description |
|---|---|
--allowed-hosts |
Comma-separated list of allowed SSH host aliases |
If --allowed-hosts is not provided, falls back to config.json in the working directory.
How It Works
- Resolve — Looks up host alias in
~/.ssh/configfor connection details - Authenticate — Tries ssh-agent → key file → password (in order)
- Connect — Opens a PTY session with
xterm-256colorterminal - Emulate — Captures output in a virtual terminal emulator
- Expose — Returns rendered screen content (with ANSI) to the MCP client
Architecture
┌──────────────────────────────────────────────────┐
│ ssh-mcp │
│ │
│ ~/.ssh/config ──► Host Resolution │
│ │
│ SSH_AUTH_SOCK ──► Authentication │
│ │
│ Sessions: │
│ ├─ tai@10.0.1.50:22 (PTY + VT) │
│ ├─ admin@web1.example.com:22 (PTY + VT) │
│ └─ ... │
│ │
│ MCP Tools ◄──► stdio transport ◄──► AI Agent │
└──────────────────────────────────────────────────┘
Development
# Build
go build -o ssh-mcp .
# Test
go test ./...
# Lint
staticcheck ./...
Related Projects
- Crush — Charm's AI coding agent
- charmbracelet/x/vt — Virtual terminal emulator
- neocrush — LSP/MCP bridge for Crush + Neovim
License
ssh MCP questions
What tools does ssh MCP provide?
It exposes 15 tools, including ssh_connect, ssh_exec, ssh_send_command, ssh_send_keys, ssh_get_screen.
How does the server authenticate with remote hosts?
It authenticates via ssh-agent, gpg-agent, or by using an SSH private key located at ~/.ssh/id_ed25519 or ~/.ssh/id_rsa.
Can I transfer files using this server?
Yes, the server supports bidirectional file and directory transfers using SFTP, including recursive transfers.
What is the difference between ssh_exec and ssh_send_command?
ssh_exec is a blocking tool used for commands that should finish (like builds or git), while ssh_send_command is non-blocking and intended for interactive TUIs like vim or htop.