mcp-ssh-terminal
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-ssh-terminalssh into staging and list running processes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-ssh-terminal
An MCP server that gives an AI agent persistent, fully interactive SSH sessions — a real shell into a remote host that behaves as if you were typing at a local terminal.
Sessions persist across tool calls — connect once, run commands, inspect output, run more; state (working directory, environment, running programs) is preserved.
A real terminal, not a command runner — arbitrary control characters (Ctrl-C, Ctrl-X, arrows, Tab, function keys) pass through faithfully, so interactive TUIs, pagers, tab-completion, and prompts all work.
Non-Unix CLIs work too — network appliances like Mikrotik RouterOS are first-class citizens because the session is a genuine PTY.
Your existing SSH setup just works —
~/.ssh/configaliases,IdentityFile, ssh-agent,ProxyJumpchains, and known_hosts are all handled by the real OpenSSH client, untouched.
ssh_connect { "host": "prod-web" } → s1 + login screen
ssh_send { "session": "s1", "text": "htop", "appendEnter": true }
ssh_send { "session": "s1", "keys": ["F5"] } → tree view, rendered
ssh_interrupt { "session": "s1" } → Ctrl-C, back to promptTable of contents
Related MCP server: Shuttle
How it works
Decision 1: drive the real OpenSSH client (ssh) inside a PTY
Rather than reimplementing SSH in JavaScript, each session spawns your actual ssh binary attached to a pseudo-terminal. Every connection requirement you'd otherwise have to hand-build is something OpenSSH already does correctly:
Requirement | How it's satisfied |
Honor |
|
ProxyJump A → B → C |
|
known_hosts verification |
|
Key-based auth |
|
Arbitrary control characters | The child runs on a PTY, so raw bytes (0x00–0x1F, 0x7F, escape sequences) reach the remote program exactly. The ssh escape char is disabled ( |
Non-Unix shells (RouterOS) | Because it's a faithful terminal (PTY + |
Uninterrupted sessions | The |
A pure-JS library (e.g. ssh2) would force us to re-implement ssh_config resolution, Match logic, ProxyJump chaining, known_hosts hashing/verification, and key handling — a large, security-sensitive surface that OpenSSH already gets right. Delegating to ssh means the server behaves exactly like your own ssh <host> command.
Decision 2: a headless terminal emulator for reading output
Raw PTY output is a byte stream full of cursor moves, colors, and redraws. Feeding that to an agent is unreadable. So output is piped through @xterm/headless, which maintains a virtual screen. Tools return the rendered screen a human would see — redraws collapsed to their final state, escape codes resolved to plain text. (A raw mode is still available on ssh_read when you need the underlying bytes.) The emulator also answers terminal queries from the remote side (cursor-position reports, device attributes), so programs that probe the terminal don't hang.
How "is the output done?" is decided
After input is sent, the server waits until output has been quiet for settleMs (default 500 ms) or a timeoutMs cap is hit, then renders. A long-running command returns partial output at the timeout with a hint to call ssh_read again — no output is lost, and short commands feel snappy.
Terminal multiplexing
Two levels:
Multiple concurrent sessions — connect to many hosts at once; each has its own session id (up to 32 concurrent).
tmux/screen inside a session — since each session is a real terminal, you can run
tmuxon the remote host and drive it with control keys (ssh_send { keys: ["C-b", "c"] }, etc.).
Requirements
Node.js ≥ 22 (
fs.glob, used by the config lister, does not exist on Node 20)The OpenSSH client (
ssh) onPATH— the same one your shell uses.macOS/Linux. (
node-ptyships prebuilt binaries; on macOS the bundledspawn-helpermust be executable — see Troubleshooting.)
Install
From npm — nothing to do up front; register it straight with npx (next section). Or install globally:
npm install -g mcp-ssh-terminalFrom source:
git clone https://github.com/zhdkirill/mcp-ssh-terminal.git
cd mcp-ssh-terminal
npm install
npm run build # compiles TypeScript to dist/
npm test # optional: runs the tests (keys, argv builder, ssh_config, live PTY sessions)Register with an MCP client
Claude Code (CLI):
claude mcp add ssh -- npx -y mcp-ssh-terminal
# or, from a source checkout:
claude mcp add ssh -- node /path/to/mcp-ssh-terminal/dist/index.jsProject-scoped .mcp.json or Claude Desktop config:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": ["-y", "mcp-ssh-terminal"]
}
}
}(For a source checkout, use "command": "node", "args": ["/path/to/mcp-ssh-terminal/dist/index.js"] instead.)
The server speaks MCP over stdio. It writes nothing to stdout except protocol traffic (logs go to stderr), so it is safe to run under any stdio MCP host.
Docker (optional)
Run it natively if you can. The whole design delegates auth to your OpenSSH — config, keys, agent, known_hosts — and a container sees none of that unless you mount it in. Docker is the right choice when the consuming machine shouldn't need Node, or you want a pinned, hermetic runtime; it is the wrong choice if you rely on ssh-agent, FIDO keys, or VPN-only routes that exist on the host.
docker build -t mcp-ssh-terminal .Register (mounting your ssh config/keys read-only):
claude mcp add ssh -- docker run -i --rm --init -v "$HOME/.ssh:/home/node/.ssh:ro" mcp-ssh-terminalNotes for container mode:
-iis mandatory (stdio transport) and--initis recommended (proper PID-1 signal handling; the server also handles SIGTERM itself).ssh-agent: Linux: add
-v "$SSH_AUTH_SOCK:/agent.sock" -e SSH_AUTH_SOCK=/agent.sock. Docker Desktop for Mac:-v /run/host-services/ssh-auth.sock:/agent.sock -e SSH_AUTH_SOCK=/agent.sock. Without an agent, mounted key files still work (you'll type passphrases interactively viassh_send).known_hosts: with a read-only mount, newly-accepted host keys can't be persisted — ssh warns and continues for that session. Mount
~/.sshread-write (or a dedicated known_hosts file) if you want them remembered.File ownership: the image runs as the
nodeuser (uid 1000). If your bind-mounted keys come through owned by a different uid and unreadable, add--user root(the container is ephemeral and has your keys mounted either way).Networking: the container has its own network namespace. Host-only routes (VPN tunnels,
localhosttargets) may need--network host(Linux only) or won't work as they do natively.
Tools
Tool | Purpose |
| Open a session to a host. Returns a session id and the initial screen (prompt, or an auth/host-key prompt to answer). |
| Send |
| Read the current screen without sending — poll long-running output. Supports |
| Send Ctrl-C to the foreground program. |
| Change terminal dimensions (affects wrapping and full-screen apps). |
| List active sessions with state, pid, age, destination. |
| Close a session and terminate its |
| List |
ssh_connect parameters
Parameter | Type | Description |
| string, required | ssh_config |
| string | Username (prepended as |
| number | Port ( |
| string | Private key path ( |
| string | ProxyJump chain ( |
| string | Run this command instead of an interactive login shell (still on a PTY) |
| string[] | Extra raw ssh arguments appended verbatim |
| boolean | Force remote PTY allocation ( |
| number | Terminal size (default 120×40) |
| number | Output-settle threshold / max wait (defaults 700 / 20000) |
| number | Max screen lines returned (default 200) |
Every screen-returning tool accepts settleMs, timeoutMs, and maxLines, and appends a status footer:
[session=s1 | state=live | wait=idle | cursor=12,1 | screen=40x120 | shown=24/40]state becomes exited code=N when the ssh process ends; wait tells you whether output settled (idle), was still streaming (timeout), or nothing new arrived (quiet).
Special keys for ssh_send
Pass an ordered keys array. Recognised tokens (case-insensitive):
Control chords:
C-c(Ctrl-C),C-x,Ctrl-d,^u,C-[(Esc),C-@(NUL),C-\,C-?(DEL) — covers all of 0x00–0x1F and 0x7F.Named keys:
Enter,Tab,Backtab,Space,Escape,Backspace,Delete,Insert,Up/Down/Left/Right,Home,End,PageUp,PageDown,F1–F12.Alt/Meta:
M-b,Alt-f,meta-.→ ESC-prefixed.Raw bytes:
hex:1b5b41→ arbitrary byte sequence.Single characters:
y,Q→ sent as-is.
Any other multi-character token is an error — a typo'd chord is rejected instead of being typed into the remote shell. Literal text belongs in text, not keys. Arrow/Home/End keys automatically switch to SS3 sequences when the remote app enables application cursor-keys mode (DECCKM), like a real terminal.
text is sent literally first, then keys in order, then Enter if appendEnter: true.
Usage walkthroughs
Basic:
ssh_connect { "host": "prod-web" }→ screen shows the shell prompt.ssh_send { "session": "s1", "text": "uname -a", "appendEnter": true }→ screen shows the output.ssh_disconnect { "session": "s1" }.
Mikrotik RouterOS:
ssh_connect { "host": "admin@192.0.2.1" }→ RouterOS banner +[admin@MikroTik] >prompt.ssh_send { "session": "s1", "text": "/interface print", "appendEnter": true }.Tab-completion:
ssh_send { "session": "s1", "text": "/ip ad", "keys": ["Tab"] }.Abort a running command:
ssh_interrupt { "session": "s1" }(Ctrl-C), or sendQto quit a pager.
RouterOS console gotchas worth knowing:
?and Tab are live hotkeys (inline help / completion) — they act the instant they arrive, so keep them out oftextunless intended, and prefer single-line commands (multi-line pastes are mangled by auto-indent; use/importfor scripts).Long
printoutput stops at a pager line (-- [Q quit|D dump|down]): sendDto dump the rest, or runprint without-paging.keys: ["C-x"]toggles Safe Mode — enter it before config changes so they auto-revert if the session drops.
ProxyJump A → B → C: use a config alias that sets ProxyJump, and just ssh_connect { "host": "internal-box" }. Or set the chain inline: ssh_connect { "host": "10.0.0.5", "jump": "bastionA,bastionB" }.
Answering auth / host-key prompts: if the initial screen shows Are you sure you want to continue connecting (yes/no)?, reply ssh_send { "session": "s1", "text": "yes", "appendEnter": true }. For a password prompt, send the password the same way. The known_hosts check is never disabled.
Long-running output: ssh_send returns at the settle/timeout; if the footer says output is still arriving, call ssh_read { "session": "s1", "waitMs": 2000 } to poll for more. ssh_read blocks until new output arrives (footer wait=idle/timeout) or reports wait=quiet if nothing new came within waitMs.
Security notes
This server hands an AI agent a real shell with your SSH identity. Read this section before wiring it into anything.
The agent can do whatever your keys can do. Every host reachable from your
~/.ssh/configand agent is reachable by the model. Use your MCP client's permission prompts (don't blanket-allowssh_send), and consider a dedicated restricted key or user for agent-driven work.Remote output is untrusted input to the model. Screen content from a remote host flows back into the agent's context; a compromised or malicious host could try prompt injection through banners, MOTDs, or command output. Treat sessions to untrusted hosts accordingly.
known_hosts verification is left on. The server does not add
StrictHostKeyChecking=noor similar; you decide, per host, by answering the fingerprint prompt.Argument injection is blocked for
host/user/jump: values starting with-are rejected and the destination is passed after a--separator, so a hostile hostname can't smuggle in ssh options likeProxyCommand.extraArgsremains a deliberate raw passthrough — treat it as you would a shell: options like-oProxyCommand=…execute local commands as the user running the server. If your MCP client supports per-tool argument review, scrutinizeextraArgs.ssh_config_hostsreads the file you point it at.configPathaccepts any path readable by the server's user (it only echoes config-shaped lines, but still). Point it at ssh configs only.Credentials are never handled by this server;
ssh/ssh-agent own them. Passwords you type viassh_sendgo straight to the PTY (not logged to stdout) — but they do transit the MCP transport and may end up in client-side conversation logs. Prefer key-based auth over typing passwords.Run it as your normal user so it inherits your
~/.sshand agent.
Troubleshooting
posix_spawnp failedfrom node-pty on macOS: the prebuiltspawn-helperlost its execute bit. Fix:chmod +x node_modules/node-pty/prebuilds/darwin-*/spawn-helper.npm run buildis unaffected, but a freshnpm installmay need this once.ssh: connect to host … Connection refused: faithfully reported from the realssh; the destination isn't listening. Session exits with code 255.Connection timed out during banner exchangeon a ProxyJump chain: OpenSSH'sConnectTimeout(default here: 30) also caps the destination's banner exchange, and that clock keeps running while you answer interactive prompts (host key, password) at the jump hop. Answer promptly, or raise it:extraArgs: ["-o", "ConnectTimeout=120"]. Note that-ooptions are not propagated to the jump hop itself — its host key is checked against your default known_hosts.channel 0: open failed: administratively prohibitedvia a jump host: the jump's sshd hasAllowTcpForwarding no(common on hardened/minimal distros, e.g. Alpine's default). Enable it on the jump host; ProxyJump needs TCP forwarding there.Output looks truncated: increase
maxLinesonssh_send/ssh_read, or poll withssh_read. The emulator keeps 5000 lines of scrollback per session.Session limit reached: at most 32 concurrent sessions; exited ones are evicted automatically, live ones must be
ssh_disconnected first.
Development
npm run build # tsc → dist/
npm test # vitest: unit tests + live PTY integration testssrc/
index.ts entry point; stdio transport + graceful shutdown
server.ts MCP server + tool definitions
manager.ts session registry + ssh argv builder
session.ts PTY + headless xterm; idle-wait + screen rendering
keys.ts key-token → byte-sequence translation
sshConfig.ts best-effort ~/.ssh/config host lister (discovery only)
test/ vitest tests (keys, argv builder, ssh_config, live PTY sessions)
Dockerfile optional container packaging (see the Docker section)Contributions welcome — please run npm test before opening a PR.
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zhdkirill/mcp-ssh-terminal'
If you have feedback or need assistance with the MCP directory API, please join our Discord server