
SSH MCP 服务器:执行命令、传输文件,并通过 MCP 转发远程服务器端口。
概览
一个MCP(模型上下文协议)服务器,为AI助手提供安全、有范围的SSH访问,访问一个或多个远程服务器。 ssh-mcp 运行于 STDIO 上,并支持任何兼容 MCP 的客户端:Claude Desktop、Claude Code、Cursor、Devin、VS Code 和 Cline。它提供了八种用于命令执行、SFTP 文件传输、目录同步、端口转发和远程系统状态收集的工具。 需要在远程服务器上运行的AI助手通常要么获得原始壳(不安全,未受保护范围),要么根本没有SSH访问权限。SSH-MCP介于两者之间:它为代理提供一套小型可审计工具,每个工具都通过可选的命令白名单/黑名单和路径限制进行门槛,因此操作员可以完全控制代理的具体操作。 - – 白名单和黑名单正则表达式模式在执行前对每个命令进行门控。没有白名单时,所有命令都被允许,启动时会记录警告。
概述(AI 翻译)
一个MCP(模型上下文协议)服务器,为AI助手提供安全保障, 对一个或多个远程服务器进行范围限制的SSH访问。
ssh-mcp 运行在 stdio 上,并支持任何兼容 MCP 的客户端:
Claude 桌面、Claude Code、光标、Devin、VS Code 和 Cline。它
提供八种命令执行、SFTP文件传输和目录工具
同步、端口转发和远程系统状态收集。
为什么它不同
需要在远程服务器上操作的AI助手通常包括以下几种
要么用一个原始外壳(不安全,没有保护区),要么完全没有SSH访问权限。
ssh-mcp 位于中间:它为代理提供一小集可审计的
每个工具都通过可选的白名单/黑名单和路径命令进行门禁
限制,因此操作员可以精确控制代理能做什么。
- 命令策略 –
whitelist和 [blacklist正则表达式模式门 执行前的每一个命令。没有白名单,所有命令都是 允许,启动时会记录警告。 - 路径限制 –
allowed_local_paths和allowed_remote_paths将SFTP传输限制在特定目录并拒绝路径 穿越。 - 通过环境变量的秘密——密码、密码短语和2FA代码包括
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
ssh-mcp
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.
Why it is different
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.
Tools at a glance
| 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 |
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"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"
}
}
}
}