使用说明
ssh-mcp服务器
MCP服务器,用于通过SSH在远程服务器上执行命令、上传和下载文件。单台服务器无需配置,只需内联传递凭据即可。
英语
ssh-mcp-server 是用于从AI工具控制SSH自动化的MCP服务器。它支持命令执行、文件上传/下载、多服务器配置、异步作业和干净的AI可读输出。
俄语
ssh-mcp-server -用于AI工具控制SSH自动化的MCP服务器。它支持命令执行、文件下载/下载、多服务器配置、后台任务和干净的AI输出。
乌克兰语
ssh-mcp-server MCP服务器,用于AI工具的控制SSH自动化。它支持命令执行,文件上传/下载,多服务器配置,后台任务和AI友好的干净输出。
特性
- 命令执行 --同步/异步模式、超时、后台轮询
- 可靠的文件传输 --5种自动回退策略
- 多服务器 --通过基于工作空间的自动选择轻松切换
- AI原生输出 --ANSI被剥离,检测到二进制,控制字符被删除
- 零配置模式 --直接在MCP配置中传递服务器凭据,不需要额外的文件
- 快 --SFTP会话缓存、连接池、64流并行传输
工具
| 工具 | 说明 |
|---|---|
ssh_servers |
列出已配置的服务器及其工作区绑定 |
ssh_execute |
运行shell命令(同步或异步轮询) |
ssh_upload |
将本地文件上载到远程服务器 |
ssh_download |
将远程文件下载到本地计算机 |
快速开始
零配置(内联)
无需文件——直接在AI工具的MCP配置中传递服务器凭据:
{
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "your-password"
]
}
}
使用配置文件
对于多服务器设置,请创建 ssh-servers.json 在您的工作目录中:
{
"servers": [
{
"id": "dev",
"name": "Dev Server",
"host": "1.2.3.4",
"username": "ubuntu",
"password": "your-password",
"workspaces": ["D:\\projects\\my-app"]
}
]
}
然后运行:
npx -y @thesashadev/ssh-mcp-server
🔌 客户端集成
Claude Code (CLI)
单服务器:
claude mcp add ssh -- npx -y @thesashadev/ssh-mcp-server --host 1.2.3.4 --username ubuntu --password secret
两台服务器:
claude mcp add ssh -- npx -y @thesashadev/ssh-mcp-server \
--host 1.2.3.4 --username ubuntu --password secret --id dev \
--host 5.6.7.8 --username deploy --key ~/.ssh/id_rsa --id prod
或者使用配置文件:
claude mcp add ssh -- npx -y @thesashadev/ssh-mcp-server
(地点 ssh-servers.json 在项目根目录中)
Claude Desktop
编辑 claude_desktop_config.json:
- 窗户:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
单服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
}
}
}
两台服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
}
}
}
Cursor
打开 设置 → 光标设置 → 主控程序 → +添加新的MCP服务器.
或添加到 ~/.cursor/mcp.json:
单服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
}
}
}
两台服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
}
}
}
Windsurf
编辑 ~/.codeium/windsurf/mcp_config.json (macOS/Linux)或 %USERPROFILE%\.codeium\windsurf\mcp_config.json (Windows):
单服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
}
}
}
两台服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
}
}
}
Antigravity
添加 mcp_config.json:
单服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
}
}
}
两台服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
}
}
}
Codex
添加 codex.toml:
单服务器:
[mcp_servers."ssh"]
command = "npx"
args = [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
enabled = true
两台服务器:
[mcp_servers."ssh"]
command = "npx"
args = [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
enabled = true
Cody (Sourcegraph)
编辑 ~/.config/cody/mcp_servers.json:
单服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
}
}
}
两台服务器:
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
}
}
}
Continue.dev
添加 .continue/config.json:
单服务器:
{
"mcpServers": [
{
"name": "ssh",
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4",
"--username", "ubuntu",
"--password", "secret"
]
}
]
}
两台服务器:
{
"mcpServers": [
{
"name": "ssh",
"command": "npx",
"args": [
"-y", "@thesashadev/ssh-mcp-server",
"--host", "1.2.3.4", "--username", "ubuntu", "--password", "secret", "--id", "dev",
"--host", "5.6.7.8", "--username", "deploy", "--key", "~/.ssh/id_rsa", "--id", "prod"
]
}
]
}
配置
配置服务器的三种方法(按优先级顺序):
1.CLI参数(零配置)
直接传入MCP配置参数:
--host 1.2.3.4 --username ubuntu --password secret
--host 1.2.3.4 --username deploy --key ~/.ssh/id_rsa
| Arg | 描述 |
|---|---|
--host |
SSH主机(启动新的服务器块) |
--port |
SSH端口(默认值:22) |
--username |
SSH用户 |
--password |
密码验证 |
--key |
私钥路径 |
--passphrase |
密钥密码 |
--id |
服务器ID(默认:“默认”) |
--name |
显示名称 |
--remote-dir |
默认远程目录 |
--workspace |
本地目录绑定 |
多台服务器:重复 --host 阻碍:
--host 1.2.3.4 --username dev --password pass1 --id dev
--host 5.6.7.8 --username prod --key ~/.ssh/id_rsa --id prod
2.环境变量
对于通过env进行的单服务器设置:
SSH_HOST=1.2.3.4 SSH_USER=ubuntu SSH_PASSWORD=secret
| 环境变量 | 描述 |
|---|---|
SSH_HOST |
SSH主机 |
SSH_PORT |
SSH端口 |
SSH_USER |
用户名 |
SSH_PASSWORD |
密码 |
SSH_KEY |
私钥路径 |
SSH_PASSPHRASE |
密钥密码 |
SSH_REMOTE_DIR |
默认远程目录 |
SSH_WORKSPACE |
本地工作区 |
3.配置文件(ssh-servers.json)
用于复杂的多服务器设置。查找位置:当前目录→ 包目录。
{
"servers": [
{
"id": "dev",
"host": "1.2.3.4",
"username": "ubuntu",
"password": "secret",
"workspaces": ["D:\\projects\\my-app"]
},
{
"id": "prod",
"host": "5.6.7.8",
"username": "deploy",
"privateKeyPath": "~/.ssh/id_rsa",
"workspaces": ["D:\\projects\\production"]
}
]
}
许可证
AGPL-3.0
