
MCP 服务器通过模型上下文协议为 Linux 服务器暴露 SSH 控制。
概览
是一个本地模型上下文协议(MCP)服务器,为Linux和Windows系统提供SSH控制,使LLM和其他MCP客户端能够通过SSH安全地执行shell命令。 - 安装SSH MCP服务器 - 配置SSH MCP服务器 - 设置MCP客户端(如Claude Desktop、光标等) - 通过自然语言在Linux或Windows服务器上执行远程shell命令 - 符合MCP标准的服务器,暴露SSH功能 - 在远程Linux和Windows系统上执行shell命令 - 通过密码或SSH密钥实现安全认证 - 使用TypeScript和官方MCP SDK构建 - 支持自动进程中止 - - 尝试在关闭连接前终止挂机进程 - exec:在远程服务器上执行 shell 命令 - - 命令(必填):在远程 SSH 服务器上执行的 shell 命令 - 描述(可选):该命令的可选描述(附加为注释) - - sudo-exec:执行带有sudo抬高的shell命令 - - 命令...
概述(AI 翻译)
SSH MCP 服务器 是一款以安全为先的模型上下文协议服务器,为LLM代理提供对远程主机的受控SSH访问——包括命令分类、基于策略的授权、人工环路审批以及完整的审计日志。
该服务器存在的风险。 在远程主机上赋予LLM壳层访问权限,将私人数据、不受信任输入和网络出口集中在一处——Simon Willison的“致命三重奏”。提示注入没有通用解决方案,因此ssh-mcp假设任何命令都可能受攻击者影响:它在执行前分类,对主机组矩阵×角色授权,破坏性工作被封锁在批准后,并记录决策。这减少了爆炸范围;但并未消除风险。两点仍属于你:绝不要指向根账户,绝不在生产配置文件上设置
auto批准。SECURITY.md 拥有完整的威胁模型。
快速启动
1.安装
2.配置
即使没有配置,服务器仍然会启动,因此客户端或目录可以完成MCP
握手并读取tools/list——但所有工具调用都被拒绝,直到你配置它,
下面附有一条信息,标明了路径。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
SSH MCP Server v2
SSH MCP Server is a security-first Model Context Protocol server that gives LLM agents controlled SSH access to remote hosts — with command classification, policy-based authorization, human-in-the-loop approval, and full audit logging.
The risk this server exists to manage. Giving an LLM shell access on a remote host puts private data, untrusted input and network egress in one place — Simon Willison’s “lethal trifecta”. Prompt injection has no general fix, so ssh-mcp assumes any command may be attacker-influenced: it classifies before executing, authorizes against a role × host-group matrix, gates destructive work behind approval, and records the decision either way. That narrows the blast radius; it does not remove the risk. Two things stay yours: never point it at a root account, and never set
autoapproval on a production profile. SECURITY.md has the full threat model.
Quick Start
1. Install
npm install -g ssh-mcp
2. Configure
Without a config the server still starts, so a client or directory can complete the MCP
handshake and read tools/list — but every tool call is refused until you configure it,
with a message naming the path below. Nothing runs on a host until this step is done. The
one exception is reload-config: write the file, then call it with action: "reload" (or
restart the server) to configure a server that is already running — see
Reloading.
Create the config file at the path for your platform:
| Platform | Path |
|---|---|
| Linux | ~/.config/ssh-mcp/config.toml (or $XDG_CONFIG_HOME/ssh-mcp/config.toml) |
| macOS | ~/Library/Application Support/ssh-mcp/config.toml |
| Windows | %APPDATA%\ssh-mcp\config.toml |
[defaults]
defaultProfile = "dev"
approvalMode = "ask-destructive"
[[profiles]]
name = "dev"
host = "192.168.1.100"
port = 22
user = "deploy" # NOT root!
auth = "key"
安装
npx ssh-mcp --host=1.2.3.4 --user=root --password=hunter2配置
{
"mcpServers": {
"ssh-mcp": {
"command": "ssh-mcp",
"env": {
"SSH_MCP_PASSWORD": "your-password"
}
}
}
}