SSH-Remote
Leverages tmux sessions on the remote host to run interactive/TTY programs (e.g. curses apps like htop) and long-running tasks, with screen capture via tmux capture-pane to inspect output and progress without holding the MCP call open.
Click on "Deploy 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., "@SSH-Remote run the full test suite in the background, then check on it"
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.
SSH-Remote
常驻 SSH 长连接的 MCP server。让 WorkBuddy / Cursor 这类 AI 编码工具直接读写远端机器、执行远端命令,而不是每次调用都新建一次 SSH 连接。
装上之后的效果,和「本地连上远程开发机干活」基本一致:搜代码、读文件、改文件、跑命令、跑长任务、TTY 交互,都在远端原生环境里完成。
为什么要它
Windows 上每次 ssh host "cmd" 的开销拆开看:
环节 | 耗时 |
创建新进程(疑似杀软实时扫描) | ~480ms |
SSH 握手 | ~420ms |
网络往返(局域网 <1ms) | 可忽略 |
也就是说真正的命令执行时间被开销完全淹没了。而 Windows 上两个 ssh 实现都不支持连接复用:
Git-MSYS:
mux_client_request_session: read from master failed: Connection reset by peerWin32-OpenSSH:
getsockname failed: Not a socket
所以 ~/.ssh/config 里配 ControlMaster 是没用的。
本项目的解法:绕开 multiplexing,改成一个常驻 Node 进程 hold 住一条 ssh2 连接,通过 MCP 暴露工具。调用时不创建进程、不重新握手。
Related MCP server: 2native-ssh-mcp
实测性能
同刻对照,Windows 本机:
方式 | 一次典型四步信息收集¹ |
| 3339ms |
本 MCP(4 次工具调用) | 177ms |
约 19 倍。单次调用:ssh 稳定 825ms,本MCP exec 50ms / search 52ms / list 82ms / read 8ms / stat 3ms。
¹ git 状态 + 代码搜索 + 读文件 + 健康检查
长连接会发心跳(15s × 3 次容错),跑完6 分钟的全量测试后健康检查仍是 14ms。首连含建连226ms,属一次性成本。
安装
npm install在 MCP 客户端的配置里注册(WorkBuddy 是 ~/.workbuddy/mcp.json):
{
"mcpServers": {
"ssh-remote": {
"command": "node",
"args": ["<绝对路径>/ssh-remote/server.js"],
"env": {
"SSH_REMOTE_HOST": "192.168.0.110",
"SSH_REMOTE_USER": "yourname",
"SSH_REMOTE_BASE": "/home/yourname/work"
}
}
}
}必填 SSH_REMOTE_HOST / SSH_REMOTE_USER / SSH_REMOTE_AUTH / SSH_REMOTE_BASE;不填会在启动时直接报错并告诉你怎么配,而不是拿着空主机名去连、报一堆看不懂的 ssh 错误。
新 server 需要在客户端的连接器管理里 Trust,并重启客户端才会加载。
Windows + Git Bash 的坑
在 Git Bash 里手动跑验证脚本时,MSYS 会把环境变量值里的 Unix 路径改写成 Windows 路径:
# ✗ SSH_REMOTE_BASE 传进 node 后变成了 C:/Program Files/Git/home/... → "No such file"
SSH_REMOTE_BASE=/home/me/proj node smoke-test.js
# ✓
MSYS_NO_PATHCONV=1 SSH_REMOTE_BASE=/home/me/proj node smoke-test.js走 MCP 配置(JSON)启动不受影响——那条路径不经过 shell。
配置
变量 | 必填 | 说明 |
| ✅ | 目标主机地址 |
| SSH 端口,默认 22 | |
| ✅ | 登录用户名 |
| ✅ | 认证方式,必填三选一: |
| 密码( | |
| 密码表路径,缺省为程序目录下的 | |
| 用户命令执行时的 PATH 前缀(冒号分隔),不设 = 不碰 PATH,保持 sshd 默认 | |
| 私钥路径,默认 | |
| ✅ | 远端工作目录,必须是绝对路径 |
|
|
SSH_REMOTE_BASE必须是绝对路径:它会被拼进远端cd "...",双引号里~不做展开。所有工具的相对路径都基于它。
换机器:改env 段,重启客户端。多台机器并行:复制一份目录,在配置里注册第二个条目、换个名字(工具前缀随之区分,如 mcp__ssh-remote-2__*)。同一台机器不需要多个 server。
认证方式
SSH_REMOTE_AUTH 必填,三选一,不做自动探测:
方式 | 配置 | 适用场景 |
密码 |
| 最省事,适合没有公钥管理流程的机器 |
私钥 |
| 常规做法,公钥 |
none(空认证) |
| 服务端本身就允许空认证的机器(某些嵌入式设备/内网测试机只校验用户名) |
没有 auto、没有 agent、没有回退——配置缺什么直接快速失败,报错带指引。
注意:SSH_REMOTE_PASSWORD=""(空串)视同未配置,不会拿空密码去撞服务端。
认证连不上时错误信息会带上排查指引(密码错 / PasswordAuthentication 被禁 / 公钥没进 authorized_keys / 服务端不接受空认证)。
密码方式示例:
"env": {
"SSH_REMOTE_HOST": "192.168.0.110",
"SSH_REMOTE_USER": "yourname",
"SSH_REMOTE_AUTH": "password",
"SSH_REMOTE_PASSWORD": "yourpassword",
"SSH_REMOTE_BASE": "/home/yourname/work"
}密码表 password.xlsx
不想把密码明文写进 MCP 配置的话,password 模式也支持从密码表读取。格式与
Remote-SSH 的 password.xlsx 完全一致,两边可以直接互拷:
第 1 列 | 第 2 列 |
主机名(与 | 密码 |
规则:
位置:缺省找程序目录下的
password.xlsx,可用SSH_REMOTE_PASSWORD_FILE指定其他路径(建议绝对路径)所有 sheet 都会扫一遍;带表头无妨(表头不会匹配到真实主机名)
优先级:
SSH_REMOTE_PASSWORD环境变量 > 密码表——设了 env 就不看表失败语义:env 和表里都没有该主机 → 启动即报错并指路;文件损坏 → 启动即报错;缺省位置的文件不存在不算错(视为没配密码表)
password.xlsx已进.gitignore,真实密码不会被提交;仓库里带模板password.example.xlsx
密码表示例:
"env": {
"SSH_REMOTE_HOST": "192.168.0.110",
"SSH_REMOTE_USER": "yourname",
"SSH_REMOTE_AUTH": "password",
"SSH_REMOTE_PASSWORD_FILE": "/home/yourname/secrets/password.xlsx",
"SSH_REMOTE_BASE": "/home/yourname/work"
}自定义 PATH
sshd 对 exec 请求跑的是非登录 shell($SHELL -c),PATH 只有系统默认值——
nvm、cargo 这类装在用户目录的工具会 command not found。
SSH_REMOTE_PATH 用来显式补 PATH:
"env": {
"SSH_REMOTE_PATH": "/home/yourname/.nvm/versions/node/v22.12.0/bin:/usr/local/go/bin"
}只影响
remote_exec/remote_exec_bg的用户命令:命令前缀export PATH=<值>,cd在其后其余环境一律不动,输出干净可预期(不引入 profile 里的 banner)
不设 / 设空 = 完全不碰 PATH,保持 sshd 默认行为;不做自动探测
取舍:PATH 值自己维护——远端升级 nvm/node 后版本目录会变,需要同步改配置
密码验证也可跑 node auth-selftest.js:不需要真实远端机,脚本内起 mock sshd,覆盖密码/私钥/none 三种模式、非法 authMode 校验、密码表解析及 PATH 命令组装共 27 项断言。
工具
工具 | 用途 |
| 执行远端命令。多条命令用 |
| 后台起长任务,立即返回 jobId,不阻塞 |
| 查任务状态( |
| 列出远端所有任务 |
| 读远端文件(带行号) |
| 写远端文件(整文件覆写) |
| 精确字符串替换,改文件不必整篇重写 |
| 远端全文搜索(rg,跨连接复用) |
| 按名找文件(fd) |
| 列目录 |
| 文件元信息 |
| 连接健康检查 |
后台长任务
长跑的东西(全量测试、构建、大批量迁移)不该占着 MCP 调用不放:
remote_exec_bg({ command: "make test-db", label: "全量测试" })
// → { jobId: "muw9a36u-e6taf", pid: "2523963" } 约 250ms 返回
remote_job_check({ jobId: "muw9a36u-e6taf" })
// → { status: "done", exitCode: 0, durationMs: 226000, log: "..." }状态全放远端 /tmp/ssh-remote-jobs/<jobId>/,所以客户端重启也能继续查(内存状态会随进程消失,进度条就没意义了)。日志不会进 git,也不会被任何目录遍历工具扫到。
边界与取舍
没有 GUI diff 视图 / 变更文件面板。原生 Read/Grep 只认本地路径,这是本机侧的限制。但
git diff本身能通过remote_exec完整拿到,AI 读文本足够。改文件是整文件覆写或精确替换,没有「光标停在某行」的细粒度编辑。对 AI 干活够用。
单条 TCP:网络抖动会让正在跑的长命令直接失败(下一跳自动重连,但这一跳会报错)。长任务建议用
remote_exec_bg。输出有上限:命令 1MB、文件 512KB、目录 500 项,超出截断。
依赖远端有
rg/fd:remote_search/remote_find需要。没装会明确报错,退回grep也行,只是慢。
TTY 交互
server 是非交互的,但远端有 tmux,所以 TTY 程序能跑:
tmux new-session -d -s htop htop
tmux capture-pane -pt htop # 抓屏看内容curses 程序、长跑任务中途看进度都适用。
验证改动
改完代码不必重启客户端就能验——探针会新建子进程加载最新代码:
node mcp-probe.js # 跑通全部工具 + 后台任务三件套
node smoke-test.js # 量化握手开销vs 连接复用
node bg-selftest.js # 拿真实长任务验「起任务不阻塞」
node auth-selftest.js # 认证自测:密码/私钥/none 三选一,不需要真实远端机安全边界
目标主机由 CONFIG 固定,工具参数无法指定别的主机——不提供任意目标跳转能力。stdout 专供 MCP 协议,所有日志走 stderr。
Available Tools
12 toolsremote_execB
在远端服务器执行命令。默认工作目录是 SSH_REMOTE_BASE 指定的目录。把多条命令用 && 串成一次调用更省时间——成本在调用次数,不在命令条数。
Inputs: command (required), cwd, timeout.
remote_exec_bgA
后台起一个远端任务,立即返回不等待。适合编译、全量测试、构建镜像这类几分钟的活——返回 jobId,之后用 remote_job_check 查结果。任务状态存在远端文件系统上,本工具重启、甚至 WorkBuddy 重启后照样能接着查。
Inputs: command (required), cwd, name.
remote_findA
在远端按文件名查找(走 fd-find,缺失时回退 find)。比 remote_list 递归快得多。
Inputs: pattern (required), path, type, maxResults.
remote_healthA
查看 SSH 长连接状态;断线时会自动重连一次。
Inputs: no named parameters.
remote_job_checkA
查一个后台任务的状态与输出。返回 running / done / failed,终态时带退出码和日志末尾若干行。
Inputs: jobId (required), tail.
remote_job_listB
列出当前所有后台任务,含在跑的和已结束的(按开始时间倒序)。
Inputs: all.
remote_listB
列出远端目录内容,返回类型、大小、修改时间。
Inputs: path, maxEntries.
remote_readB
读取远端文件。支持按行区间读取,返回带行号以便后续精确修改。
Inputs: path (required), endLine, maxBytes, startLine.
remote_replaceB
在远端文件里做精确字符串替换,无需传整个文件。old_string 必须唯一匹配,否则报错——这是为了防止改错地方。
Inputs: path (required), newString (required), oldString (required), replaceAll.
remote_searchA
在远端按内容搜索(优先 ripgrep,远端没装时回退 grep)。适合跨文件找符号、找引用。
Inputs: pattern (required), path, type, context, +3 more.
remote_statB
查看远端文件或目录是否存在及其属性(类型、大小、修改时间、权限)。
Inputs: path (required).
remote_writeB
整文件写入远端。改大文件前建议先 remote_read 确认内容。
Inputs: path (required), content (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Each tool targets a distinct action: read/write/replace for content, list/find/stat for path discovery, and search for content grep. The potentially confusable pairs (remote_search vs remote_find, remote_list vs remote_find, remote_stat vs remote_list) are explicitly separated in the descriptions by content-vs-name and single-path-vs-directory semantics. Foreground exec vs background exec_bg vs job_check/job_list are also cleanly separated.
All tools share a uniform `remote_` prefix in snake_case, which makes the family immediately recognizable. Minor deviation: the background-job lifecycle splits across two stems (`remote_exec_bg` to start vs `remote_job_check`/`remote_job_list` to inspect), and `remote_health` is a noun rather than a verb, so the pattern is not perfectly uniform.
Twelve tools is well within the healthy range and every tool maps to a real operation in the remote file/exec domain. The split between foreground and background execution is justified by the stated use case of long-running builds and test suites, not padding.
Core lifecycle is well covered: read/write/replace for editing, list/find/stat for inspection, search for content lookup, and exec plus a full background-job start/check/list flow. Gaps are minor: no way to cancel or kill a background job, no delete/move/mkdir/rename primitives, and no tail-follow for running job output — though all of these can be worked around via `remote_exec`.
Maintenance
Related MCP Connectors
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Remote shell and detached long-running jobs on your own machines — no SSH, open ports or VPN.
Give your AI hands on every computer you own. Remote control of your Windows, Mac and Linux machines from one ChatGPT, Claude or Cursor chat — even from your phone. Ask it to find out why the office server is crawling, update every PC in the house, sort out your mom's laptop from another city, or ship the site from your work machine while you're on a train. It runs commands and reads and writes files; screenshots are a beta you can request. You decide what each computer allows, and you can cut any of them off in a second.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to have persistent, fully interactive SSH sessions into remote hosts, behaving like a local terminal.19 npm2MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to remotely execute shell commands and transfer files on SSH hosts, including jump-host tunneling, background tasks, resumable transfers, and optional approval of destructive commands, while SSH credentials remain in the local process. It runs over stdio or a streamable HTTP daemon and supports auditing, allow/deny lists, and multiple authentication methods.ISC
- AlicenseAqualityCmaintenanceEnables AI assistants to run shell commands, read, write, edit, search, and stream files on remote SSH servers and Docker containers, including nested multi-layer chains, without installing any runtime on the target hosts. It auto-injects a self-contained Go helper with adaptive zstd compression for fast transfers and process control.9MIT
- AlicenseAqualityCmaintenanceEnables AI coding tools to read, write, search, and list files on remote machines and run commands there, including background long-running jobs and TTY-based interaction, all through a single persistent SSH connection. Bypasses the cost of establishing a new SSH session on every call, cutting typical multi-step remote operations from seconds to milliseconds.12MIT