Skip to content
MCP server
Registry

remote-ssh-mcp MCP Server

Persistent stateful remote SSH sessions for AI agents via MCP + OpenSSH.

remote-ssh-mcp scores 70 (Good), licensed MIT and written in TypeScript. It installs as a local process. It declares 4 tools. Filed under AI and memory. GitHub shows 1 stars. Package registries report about 88 downloads a week. Install configs are generated for 12 clients. Being listed in the registry is not the same as being vendor-official.

by the-nine-nationMITTypeScript1 stars
Trust score
70Good
Trust score 70 of 100, Good

Good trust

70 of 100 from six public signals. Nobody can buy a point.

  • Listed in the official MCP registry.
  • OSI-style license: mit.
How we score trust
Scorecard

License, quality and maintenance

How grades work
Trust breakdown

Where the 70 comes from

22 + 20 + 4 + 10 + 4 + 10 = 70. Each factor is capped, so no single signal can carry a listing.

Registry22 / 30

Active in the official MCP registry, plus a known vendor namespace.

Registry: 22 of 30 points.
Maintenance20 / 20

How recently the repository saw a commit or release.

Maintenance: 20 of 20 points.
Popularity4 / 20

GitHub stars and weekly downloads, on a log scale.

Popularity: 4 of 20 points.
License10 / 10

A clear, OSI-style open-source license.

License: 10 of 10 points.
Security4 / 10

Not archived, a secure install path, a pinned version.

Security: 4 of 10 points.
Docs10 / 10

A real summary, a README with depth, listed tools.

Docs: 10 of 10 points.

Install

Pick your client, copy the config, paste it in.

Needs Cursor or VS Code installed on this device. The button opens the app and asks you to confirm before it adds the server.

~/Library/Application Support/Claude/claude_desktop_config.json
{  "mcpServers": {    "the-nine-nation-remote-ssh-mcp": {      "command": "npx",      "args": [        "-y",        "@zyluo/remote-ssh-mcp@0.2.0"      ],      "env": {        "SSH_MCP_ALLOWED_HOSTS": "",        "SSH_MCP_CONFIG": ""      }    }  }}

Environment variables

NameRequiredNotes
SSH_MCP_ALLOWED_HOSTSOptionalComma-separated additional SSH Host aliases to allow
SSH_MCP_CONFIGOptionalPath to remote-ssh-mcp config.json

Tools4Tool docs quality grade C

All capabilities
  • optional reload boolean

  • host (required Host alias), optional name label

  • id, optional lines (default 50, max 1000), optional waitsec

  • id, command, optional waitsec, optional timeoutsec

About


Why Remote SSH MCP?

Most agents reach remote machines like this:

bash โ†’ ssh host "cmd" โ†’ disconnect โ†’ repeat

Every call pays the same tax:

PainWhat happens
๐Ÿ” Token wasteBanners, MOTD, login noise, and pwd / whoami probes flood the context
๐ŸงŠ Lost statecwd, export, venv activation, and shell side effects vanish
๐Ÿ”Œ UnstableFresh connects hit timeouts, host-key prompts, ProxyJump, and auth jitter
๐ŸŒ€ Error spiralThe model compensates with longer probe commands โ†’ more tokens

Remote SSH MCP turns a long-lived remote Bash into first-class MCP tools. One session ID keeps working directory, environment variables, and shell side effects. Open a new session when you need a clean environment.

Why pick this over one-shot ssh in bash?

Concrete gains for agent workflows (multi-step remote work: deploy, debug, build, inspect logs):

DimensionOne-shot ssh host "โ€ฆ"Remote SSH MCP
๐Ÿ’ฐ TokensEach step re-pays connect noise + state probes; models often re-cd / re-pwdPay once on ssh_open; later ssh_run returns mostly command output. Structured tools + head/tail caps cut tool-result bloat. In multi-step sessions this commonly cuts remote-tool context by ~50โ€“80% vs reconnect-every-time (exact savings depend on MOTD size and how chatty the model is).
โœ… Success rateN steps โ‰ˆ N handshakes โ†’ N chances to fail (timeout, jump, agent, host key)One handshake per session; subsequent commands ride a live shell. Long jobs use running + ssh_peek instead of killing the tool call and restarting. Fewer reconnects โ†’ far fewer false โ€œSSH failedโ€ loops mid-task.
๐Ÿงณ PortabilityRemote needs nothing extra โ€” but every agent machine reimplements the same brittle ssh โ€ฆ patternsInstall once on the machine that runs Claude / Cursor / Grok / etc. Remote hosts install nothing (no Node, no MCP daemon, no agent). Only a normal shell account + tools already required for SSH (bash, base64, stty, โ€ฆ). Keys and jump hosts stay in local ~/.ssh/config.
๐Ÿง  Model ergonomicsModel invents ssh strings, escapes, and recoveryStable tools: open โ†’ run โ†’ peek โ†’ close. Session id is the only handle.
๐Ÿ” Trust boundaryEasy to over-expose keys or prompt for passwords in-bandOpenSSH client only; tools never accept passwords or private-key material

Portability in one line: put the MCP on your dev box / AI host; every server already in your SSH config is reachable โ€” zero package install on the remote fleet.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         SSH (OpenSSH)         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Your laptop / CI agent โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ โ”‚  prod / staging  โ”‚
โ”‚  Claude ยท Cursor ยท Grok โ”‚     ~/.ssh/config ยท agent     โ”‚  no MCP install  โ”‚
โ”‚  + remote-ssh-mcp       โ”‚                               โ”‚  plain Bash OK   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Token sketch (illustrative multi-step remote debug):

One-shot path (per step ร— 8):
  ssh wrapper + banner/MOTD + pwd/whoami + re-cd + command output
  โ†’ noise dominates; context fills with reconnect junk

Session path:
  ssh_open  โ†’ once (handshake + READY)
  ssh_run ร— 8 โ†’ mostly the real stdout/stderr (truncated head+tail)
  โ†’ context stays on the work product, not the transport

It does not reimplement SSH. Your system OpenSSH client stays in charge โ€” so ~/.ssh/config, known hosts, the SSH agent, ProxyJump routes, and hardware keys keep working exactly as they already do.

ssh_hosts()              โ†’ discover allowed Host aliases
ssh_open(host)           โ†’ session id
ssh_run(id, command)     โ†’ same cwd + env as last time
ssh_peek / ssh_interrupt โ†’ observe or recover long / stuck work
ssh_close(id)            โ†’ release the shell and connection

Features

๐Ÿง  Persistent remote sessions

  • One stable session ID maps to one long-lived remote Bash
  • cwd and environment survive across ssh_run calls
  • Open a fresh session whenever you need a clean slate
  • Multiple sessions can target the same or different hosts (up to maxSessions)

๐Ÿ”ง Native OpenSSH integration

  • Spawns the real ssh binary โ€” no custom crypto stack
  • Honors ~/.ssh/config, Include, agent sockets, and ProxyJump
  • Forces BatchMode=yes and StrictHostKeyChecking=yes
  • Never accepts passwords, private-key text, or arbitrary SSH option args from the model

๐Ÿ“ก Long-running command friendly

  • ssh_run waits up to wait_sec (default 10s), then returns status: "running" while the remote command continues
  • Poll with ssh_peek(wait_sec=...) long-poll instead of busy-looping
  • Optional hard timeout_sec sends Ctrl-C; no automatic kill by default
  • Ideal for docker pull, builds, downloads, and deploys that must not block the tool call forever

๐Ÿ›ก๏ธ Safety & control plane

  • Exact Host-alias allowlist from ssh_config + optional config / env overrides
  • Patterns with *, ?, or ! are ignored
  • Fail-closed interrupt: if shell recovery cannot be confirmed after Ctrl-C, the session is closed
  • Built-in denylist for a few obviously destructive patterns (not a full policy engine)
  • Idle reaping, session caps, and a JSONL audit log (0600) with hashed commands

๐Ÿ“ฆ Clean tool results for models

  • Separate stdout / stderr streams
  • Head-and-tail byte truncation with valid UTF-8 boundaries
  • ANSI / PTY noise stripped before the model sees output (colors, CSI, bracketed-paste markers, control-only blank lines)
  • Quiet open-frame: TERM=dumb, NO_COLOR, bracketed-paste off โ€” less junk at the source
  • Slim JSON payloads: omit empty stderr, false truncation flags, and request-echo fields so dual content + structuredContent stays cheap
  • ssh_hosts returns only safe metadata: alias, hostname, user, port, proxy_jump
  • Never leaks IdentityFile, certificates, agent sockets, or ProxyCommand

๐Ÿ”Œ MCP-native

  • stdio transport for Claude Desktop, Cursor, and other MCP hosts
  • Compatible with both legacy and current MCP handshakes
  • Parent / stdio exit closes every tracked SSH connection

How it works

flowchart LR
  A[AI Agent] -->|MCP tools| B[Remote SSH MCP]
  B -->|spawn| C[OpenSSH client]
  C -->|SSH + PTY| D[Remote Bash]
  D --> E[(cwd / env / side effects)]

  subgraph Local machine
    B
    C
    F[~/.ssh/config<br/>agent / keys]
    C -.-> F
  end

  subgraph Remote host
    D
    E
  end

Typical agent flow

1. ssh_hosts()                 # pick an alias from the allowlist
2. ssh_open(host="prod")       # get session id "s_โ€ฆ"
3. ssh_run(id, "cd app && โ€ฆ")  # state sticks to this id
4. ssh_run(id, "npm test")     # still in app/, env preserved
5. ssh_peek(id, wait_sec=20)   # long-poll a slow job
6. ssh_close(id)               # clean up when done

MCP tools

ToolWhat it does
๐Ÿ—‚๏ธ ssh_hostsList allowed Host aliases (safe metadata only). Pass reload=true after editing ~/.ssh/config
๐Ÿ”“ ssh_openOpen a clean persistent shell for an allowed Host alias โ†’ returns session id
โ–ถ๏ธ ssh_runRun a non-interactive command in an existing session
๐Ÿ‘€ ssh_peekLatest N lines of output + status; optional wait_sec long-polls while running
โ›” ssh_interruptSend Ctrl-C and wait for confirmed shell recovery
๐Ÿ“‹ ssh_listList sessions, cwd, state, idle countdown, and capacity
๐Ÿ”’ ssh_closeTear down remote temp state and close the connection

Tool parameters (essentials)

ToolKey params
ssh_openhost (required Host alias), optional name label
ssh_runid, command, optional wait_sec, optional timeout_sec
ssh_peekid, optional lines (default 50, max 1000), optional wait_sec
ssh_interrupt / ssh_closeid
ssh_hostsoptional reload boolean

Quick start

Requirements

RequirementNotes
Node.js20 or newer
OpenSSH clientSystem ssh on PATH (or set sshPath)
Remote hostBash + base64, stty, mkdir, cat, rm
SSH setupHost alias in ~/.ssh/config, host key already trusted

โš ๏ธ First-time host-key confirmation and authentication must be completed in a normal terminal. The MCP server never shows password or trust prompts.

Install

git clone https://github.com/the-nine-nation/remote-ssh-mcp.git
cd remote-ssh-mcp
npm install
npm run build
npm test

Run the server:

node /absolute/path/to/remote-ssh-mcp/dist/index.js

Or install from npm (once published):

npx @zyluo/remote-ssh-mcp
# or
npm install -g @zyluo/remote-ssh-mcp
remote-ssh-mcp

Or, after a local package install from this repo, use the remote-ssh-mcp executable.

MCP host configuration

Most stdio hosts accept a shape like this (outer key may differ by product):

{
  "mcpServers": {
    "remote-ssh": {
      "command": "node",
      "args": [
        "/absolute/path/to/remote-ssh-mcp/dist/index.js"
      ],
      "env": {
        "SSH_MCP_ALLOWED_HOSTS": "prod,staging"
      }
    }
  }
}

Cursor ยท Claude Desktop ยท Claude Code ยท other MCP-capable hosts: point command / args at the built dist/index.js and set SSH_MCP_ALLOWED_HOSTS (or rely on auto-discovery from ~/.ssh/config).

SSH_MCP_ALLOWED_HOSTS adds aliases to the allowlist. By default the server also discovers exact Host entries from ~/.ssh/config and its Include files. Tool inputs accept only safe aliases โ€” not user@host, ports, or extra SSH options.

After editing ~/.ssh/config, call ssh_hosts(reload=true) instead of restarting the server.

Credential boundary

Authentication stays inside the local OpenSSH client:

  • Tools never accept passwords or private-key material
  • ssh_hosts never returns key paths, certs, agent sockets, or ProxyCommand
  • Agents should call ssh_open with a Host alias and must not read ~/.ssh private keys from disk

Configuration

Optional config file (default path):

~/.config/remote-ssh-mcp/config.json
{
  "allowedHosts": ["prod", "staging"],
  "sshConfigPath": "~/.ssh/config",
  "sshPath": "ssh",
  "maxTimeoutSec": 1800,
  "defaultWaitSec": 10,
  "maxWaitSec": 30,
  "openTimeoutSec": 20,
  "idleTimeoutSec": 1800,
  "interruptGraceSec": 5,
  "maxSessions": 8,
  "outputMaxBytes": 32768,
  "outputHeadBytes": 4096,
  "auditLogPath": "~/.local/state/remote-ssh-mcp/audit.jsonl"
}

Environment variables

VariablePurpose
SSH_MCP_CONFIGConfiguration file path
SSH_MCP_ALLOWED_HOSTSComma-separated additional Host aliases
SSH_MCP_SSH_CONFIGSSH config path
SSH_MCP_SSH_PATHOpenSSH executable
SSH_MCP_MAX_TIMEOUT_SECMax explicit command timeout
SSH_MCP_DEFAULT_WAIT_SECHow long ssh_run waits before returning running
SSH_MCP_MAX_WAIT_SECMax wait_sec on ssh_run / ssh_peek
SSH_MCP_OPEN_TIMEOUT_SECConnect / handshake timeout
SSH_MCP_IDLE_TIMEOUT_SECIdle session lifetime
SSH_MCP_INTERRUPT_GRACE_SECMarker recovery grace after Ctrl-C
SSH_MCP_MAX_SESSIONSMaximum live sessions
SSH_MCP_OUTPUT_MAX_BYTESPer-stream retained output limit
SSH_MCP_OUTPUT_HEAD_BYTESRetained head bytes when truncating
SSH_MCP_AUDIT_LOGJSONL audit-log path

Environment variables override the file. The audit log is created with mode 0600 and records session, host, result, duration, command length, command name, and SHA-256 โ€” not full argument strings (reduces secret leakage).


Execution semantics

Detailed rules the agent (and you) should know:

TopicBehavior
ConcurrencyOne session runs one foreground command at a time; extra ssh_run โ†’ busy
wait_secLimits only how long the MCP call waits. On expiry: status: "running", remote work continues
Do not retryNever re-issue the same long command after running โ€” poll with ssh_peek
Hard timeoutOnly an explicit timeout_sec creates a deadline that sends Ctrl-C
ssh_peekDefault last 50 lines (max 1000); byte caps still apply; optional long-poll wait_sec
stdinUser commands get /dev/null โ€” no vim, top, or interactive installers
Interrupt recoveryCtrl-C + grace period for protocol marker; if recovery fails โ†’ session closed (fail-closed)
Outputstdout / stderr keep head + tail independently; always valid UTF-8 boundaries
DenylistBlocks a few high-risk patterns only โ€” not a complete policy engine
Trust modelLocal trusted developer tool โ€” not a multi-tenant remote execution service
Host exitMCP host / stdio death closes all SSH connections; nohup / setsid jobs may survive

Example: start docker pull with wait_sec: 10 and no timeout_sec. A running result means the original pull is still active โ€” do not start another. Call ssh_peek with a positive wait_sec until idle, interrupt it, or open another session for parallel work.


Development

npm run typecheck
npm test
npm run build
npm audit --omit=dev

The test suite covers MCP stdio discovery and calls, persistent cwd / environment state, stream separation, framing across arbitrary chunk boundaries, timeout fail-closed behavior, shell death, allowlist discovery, output truncation, and the safety denylist.

Design notes and wire protocol: ่ฟœ็จ‹SSH-MCP่ฎพ่ฎก.md.


Security

Please do not report security vulnerabilities through public GitHub issues. Until a private advisory workflow is configured, contact the maintainer via the email on their GitHub profile.

Remote commands can have irreversible side effects even when the MCP transport is healthy. Use least-privilege accounts, keep the allowlist narrow, and review host permissions carefully.


Project status

ItemStatus
Version0.2.2
LicenseMIT
LanguageTypeScript (Node โ‰ฅ 20)
ProtocolMCP over stdio
Transport to hostSystem OpenSSH

Changelog

Unreleased โ€” Connection and progress feedback

  • Custom sshConfigPath / SSH_MCP_SSH_CONFIG now controls the actual connection through OpenSSH -F, as well as host discovery. The default ~/.ssh/config keeps native OpenSSH behavior; a custom file follows -F semantics (system-wide config is skipped).
  • Host discovery also accepts Host=prod, HostName = example.com, and Include=... syntax.
  • ssh_open failures include a reason and actionable hint for host trust, authentication, DNS, network, timeout, and local setup issues, alongside the original error.
  • Short progress output is delivered immediately unless its suffix could be a partial protocol marker.
  • Completed ssh_peek responses include command_status and duration_ms, keeping shell state (idle) separate from the command outcome. A peek already waiting when a session dies retains available output and timeout/interruption details. Later calls to the removed session still return session_gone.

0.2.2 โ€” quieter remote output, fewer tokens

PTY-backed interactive bash often injects escape sequences that look like โ€œbinaryโ€ when JSON-escaped (\u001b[?2004h, color CSI, cursor codes). That noise burned context on every ssh_peek / ssh_run.

ChangeWhat it does
Present-time sanitizeStrip ANSI/OSC/CSI, honor CR overwrite (progress bars), drop control-only blank lines, then apply the lines window
Quiet session openExport TERM=dumb / NO_COLOR / CLICOLOR=0, disable bracketed paste, send \033[?2004l once at open
Slim tool payloadsDrop empty stderr, false flags (truncated, interrupted, โ€ฆ), and echoed lines; keep empty stdout so silence stays explicit
TestsCoverage for sanitize, open-frame quieting, session present path, and slim JSON

Upgrade: npm i -g @zyluo/remote-ssh-mcp@0.2.2 (or bump the package in your MCP config), then restart the MCP process so the new server binary is loaded.

0.2.1

  • Fix READY-marker parsing when the open frame is PTY-echoed

0.2.0

  • Initial public release on npm / GitHub

Star History

If this project saves you tokens and flaky reconnects, a โญ on GitHub helps others find it.

Frequently asked questions

What is remote-ssh-mcp MCP Server?

Persistent stateful remote SSH sessions for AI agents via MCP + OpenSSH.

How do I install remote-ssh-mcp MCP Server in Claude Desktop, Cursor, or VS Code?

Pick your client in the Install section on this page and copy the generated config into the client's config file. Step-by-step guides: Claude Desktop, Cursor, and VS Code. remote-ssh-mcp MCP Server runs locally from the npm package @zyluo/remote-ssh-mcp with the command npx -y @zyluo/remote-ssh-mcp@0.2.0.

Is remote-ssh-mcp MCP Server free and open source?

Yes. remote-ssh-mcp MCP Server is released under the MIT license, an OSI-approved open-source license, so you can use, modify, and self-host it under those terms.

Does remote-ssh-mcp MCP Server support remote (HTTP) connections?

No remote endpoint is listed for remote-ssh-mcp MCP Server. It runs locally on your machine over stdio, started by your MCP client.

What tools does remote-ssh-mcp MCP Server provide?

remote-ssh-mcp MCP Server provides 4 tools: ssh_hosts, ssh_open, ssh_peek, and ssh_run. See the full tool list for descriptions and parameters.

How is remote-ssh-mcp MCP Server's trust score calculated?

remote-ssh-mcp MCP Server scores 70 out of 100 (Good). The score adds six capped public signals: registry status, maintenance, popularity, license, documentation, and security. Nobody can pay for points. Read the methodology for the full formula.

Reviews

No reviews yet

โ€”Be the first to review

5 star0 reviews at 5 stars
4 star0 reviews at 4 stars
3 star0 reviews at 3 stars
2 star0 reviews at 2 stars
1 star0 reviews at 1 stars

No published reviews yet. Used it? Tell the next person how it went.

Add badge to your README

Paste either snippet into the repository README. The image links to this listing.

Listed on MCPpedia

Top 5 MCP servers

Daily or weekly. Confirm by email, unsubscribe any time.

How often

Manage this listing

Claim this server