SSH MCP Server
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 MCP Server connect to us-prod and run 'uptime'"
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 MCP Server
A secure remote server management tool based on MCP protocol, supporting SSH connections, command execution, and SFTP file transfers.
The only MCP SSH tool that truly prevents AI from accidentally running commands on the wrong server.
If you find this project helpful, please give it a star on GitHub! Your support helps us improve!
Why SSH MCP Server?
Managing remote servers with AI assistants is powerful -- but also dangerous. When multiple servers are connected, AI models frequently mix up which server they're operating on. One wrong rm -rf on a production server, and you're in trouble.
SSH MCP Server is built from the ground up to solve this problem. Every safety mechanism is enforced server-side with cryptographic tokens -- the AI cannot bypass them, no matter what.
Safety guarantees other tools don't have:
Target Lock -- Tracks which server the AI is currently operating on. If it tries to switch targets, it must confirm first. No silent mistakes.
Alias-based routing -- Save servers with aliases like
us-prodorjp-staging, then useexec(alias: "us-prod")instead of raw IPs. Harder to mix up.Dangerous command detection -- 60+ patterns covering Docker, Kubernetes, databases, system commands. All require cryptographic token confirmation.
Multi-connection enforcement -- When multiple servers are connected, every operation MUST specify the target. No ambiguous defaults.
Environment labels -- Mark servers as
production/staging/test. Every command output shows which environment it ran on.
Related MCP server: MCP SSH Tools Server
Features
SSH Connection Management - Password/key authentication with connection pooling, private key supports both content and file path
Command Execution - Regular commands, sudo commands, batch execution, shell mode (bastion hosts)
SFTP Operations - Upload, download, list directories, create/delete files
Server Management - Save/list/remove server configurations with alias support
Credential Security - System Keychain encrypted storage (macOS/Windows/Linux)
Audit Logging - Records all operations with sensitive data masking
Persistent Shell Sessions - Multi-round interaction for bastion host scenarios
Target Lock Protection - Prevents AI from accidentally running commands on the wrong server
What's New
v0.8.1 (Latest)
Private Key File Path Support -
privateKeyparameter now accepts both key content and file pathsPreviously you had to paste the entire key content; now you can just pass a path like
/path/to/id_rsa.pemor~/.ssh/id_rsaAuto-detects format:
-----BEGINprefix = key content, otherwise treated as file pathSupports
~home directory expansion
v0.7.0
Target Lock: Server Switch Protection - The core safety feature for multi-server scenarios
Tracks the AI's current operation target; switching servers requires explicit confirmation with a cryptographic token
Single server: zero overhead. Multi-server, same target: zero overhead. Only triggers on actual target switch.
Works across all tools: exec, exec_sudo, exec_shell, shell_send, and all SFTP operations
If both target switch and dangerous command confirmations are needed, they run in sequence (switch first)
Alias Support for All Tools - Use server aliases instead of raw host/port/username
exec(alias: "us-prod", command: "ls")-- routes to the saved server configurationAvailable on all exec and SFTP tools via the new
aliasparameter
Server Environment Labels in All Outputs - Every command result now shows
[Server: us-prod (root@1.2.3.4) | Env: PRODUCTION]No longer limited to production only -- all environments are labeled
SFTP Multi-Connection Safety - SFTP operations now enforce the same multi-connection safety checks as command execution
SFTP results include
serverfield with full identity information
Connect shows active connections - When connecting a second server, the response lists all active connections as a reminder
v0.6.0
Server Identity System - Commands return full server identity (host, port, username, environment, alias)
Confirmation Token Mechanism - Cryptographic tokens replace boolean flags; AI cannot forge confirmations
60+ Dangerous Command Patterns - Docker, Kubernetes, databases, system services, Git, network, package managers
Multi-Connection Enforcement - Must specify target when multiple connections are active
v0.5.0
Persistent Shell Sessions -
shell_send,shell_read,shell_closefor multi-round bastion host interaction
View Full Changelog | All Releases
📦 Quick Start
Option 1: Run with npx (Recommended)
npx @erliban/ssh-mcp-serverOption 2: Global Installation
npm install -g @erliban/ssh-mcp-server
ssh-mcp-serverOption 3: Build from Source
git clone https://github.com/jiahuidegit/ssh-mcp-server.git
cd ssh-mcp-server
npm install
npm run build🔄 Update to Latest Version
If using npx (Recommended)
npx automatically uses the latest version, just restart your MCP client:
# No manual update needed, npx always fetches latest
npx @erliban/ssh-mcp-serverIf globally installed
# Update to latest version
npm update -g @erliban/ssh-mcp-server
# Or reinstall
npm install -g @erliban/ssh-mcp-server@latestCheck current version
npm list -g @erliban/ssh-mcp-server🎮 MCP Client Configuration
This server supports all MCP-compatible clients. Here's an example with Claude Desktop:
Edit the configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ssh": {
"command": "npx",
"args": ["-y", "@erliban/ssh-mcp-server"],
"env": {
"SSH_MCP_LOG_LEVEL": "info"
}
}
}
}For other MCP clients, please refer to their respective documentation for configuration methods.
⚙️ Environment Variables
Variable | Description | Default |
| Log level (debug/info/warn/error) |
|
| Log file path | stderr |
| Connection timeout (ms) |
|
| Command timeout (ms) |
|
| Idle connection timeout (ms) |
|
| Maximum connections |
|
| Data directory |
|
| Master password for file storage | - |
🛠️ MCP Tools
Connection Management
Tool | Description |
| Establish SSH connection (password/key auth) |
| Disconnect specific or all connections |
Server Management
Tool | Description |
| Save server configuration locally |
| List saved servers (supports group filtering) |
| Remove server configuration |
Command Execution
Tool | Description |
| Execute remote command (supports alias routing) |
| Execute with sudo privileges |
| Batch execute on multiple servers |
| Execute via interactive shell (for bastion hosts) |
| Send input to persistent shell session |
| Read shell session output buffer |
| Close persistent shell session |
SFTP Operations
Tool | Description |
| List directory contents (supports alias routing) |
| Upload file |
| Download file |
| Create directory |
| Delete file or directory |
System Tools
Tool | Description |
| Check connection status |
| Get audit logs |
| List all active connections with environment labels |
💡 Usage Examples
Connect and Execute Command
User: Connect to 192.168.1.100 with username root and password 123456
Claude: [calls connect tool]
Connected to root@192.168.1.100:22
User: Check system load
Claude: [calls exec tool]
10:30:01 up 45 days, 2:15, 1 user, load average: 0.15, 0.10, 0.05Upload Deployment File
User: Upload local /tmp/app.jar to server's /opt/app/
Claude: [calls sftp_upload tool]
Uploaded /tmp/app.jar -> /opt/app/app.jarBatch Check Server Status
User: Check disk usage on all production servers
Claude: [calls list_servers, then exec_batch]
Server 10.0.0.1: 45% used
Server 10.0.0.2: 62% used
Server 10.0.0.3: 78% used ⚠️Security Notes
Target Lock - Tracks the AI's operation target; switching servers requires cryptographic token confirmation. Prevents the #1 cause of AI server misoperations.
Credential Storage - Prefers system Keychain (macOS Keychain, Windows Credential Manager). Falls back to AES-256-GCM encrypted file storage when no desktop environment is available.
Log Masking - Passwords, private keys, and other sensitive information are automatically masked.
Dangerous Commands - 60+ patterns detected. All require token confirmation. Production environments get extra warnings.
Connection Pool - Automatically cleans up idle connections to prevent resource leaks.
Multi-Connection Safety - When multiple servers are connected, every operation must explicitly specify the target server.
📊 Star History
🤝 Contributing
Issues and Pull Requests are welcome!
📄 License
This project is licensed under the MIT License.
⭐ If you find this project helpful, please give it a star!
🤝 Feel free to open issues for questions or submit PRs for improvements!
Available Tools
20 toolsconnectA
建立 SSH 连接。两种方式二选一:(1) 通过 alias 连接已保存的服务器;(2) 通过 host + username + password/privateKey 直接连接。使用 alias 时可额外传 password/privateKey 覆盖已存储的凭证。
Inputs: alias, host, port, username, +4 more.
disconnectC
断开 SSH 连接
Inputs: host, port, username, all.
execA
在远程服务器执行命令。必须指定目标服务器:使用 alias(推荐,需先 save_server)或使用已连接的 host。只有一个活跃连接时可省略目标。多服务器场景下切换目标时会要求确认。危险命令需要 confirmationToken。
Inputs: command (required), alias, host, port, +6 more.
exec_batchA
在多台服务器批量执行命令。批量操作风险极高!包含生产环境服务器时会有特别警告。危险命令需要 confirmationToken。
Inputs: command (required), servers (required), timeout, confirmationToken.
exec_shellA
通过交互式 shell 模式执行命令(用于堡垒机穿透等不支持 exec 的场景)。必须指定目标服务器:使用 alias(推荐)或 host。只有一个活跃连接时可省略目标。
Inputs: command (required), alias, host, port, +5 more.
exec_sudoA
以 sudo 权限执行命令。必须指定目标服务器:使用 alias(推荐)或 host。只有一个活跃连接时可省略目标。多服务器场景下切换目标时需确认。危险命令需要 confirmationToken。
Inputs: command (required), sudoPassword (required), alias, host, +6 more.
get_logsC
获取操作审计日志
Inputs: limit, server, operation, level.
health_checkB
检查 SSH 连接健康状态
Inputs: host, port, username.
list_active_connectionsA
列出当前所有活跃的 SSH 连接,包含服务器环境标签(production/staging/test/development)和别名信息,帮助 AI 识别当前连接的是哪些服务器
Inputs: no named parameters.
list_serversA
列出已保存的服务器配置
Inputs: group.
remove_serverA
删除已保存的服务器配置。删除任何服务器都需要先获取 confirmationToken,生产环境服务器会有特别警告。
Inputs: alias (required), confirmationToken.
save_serverA
保存服务器配置和凭证。覆盖现有配置时需要先获取 confirmationToken。强烈建议设置 environment 字段以防止误操作生产服务器。
Inputs: alias (required), host (required), username (required), authType (required), +8 more.
sftp_downloadA
从远程服务器下载文件到本地。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: remotePath (required), localPath (required), alias, host, +4 more.
sftp_lsA
列出远程目录内容。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: path (required), alias, host, port, +2 more.
sftp_mkdirA
在远程服务器创建目录。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: path (required), alias, host, port, +3 more.
sftp_rmB
删除远程文件或目录。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: path (required), alias, host, port, +3 more.
sftp_uploadA
上传本地文件到远程服务器。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: localPath (required), remotePath (required), alias, host, +4 more.
shell_closeA
关闭持久化 shell 会话。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: alias, host, port, username.
shell_readA
读取持久化 shell 会话的输出缓冲区。使用 alias(推荐)或 host 指定目标服务器,单连接时可省略。
Inputs: alias, host, port, username, +1 more.
shell_sendA
发送输入到持久化 shell 会话(用于多轮交互,如堡垒机穿透登录流程)。必须指定目标服务器:使用 alias(推荐)或 host。只有一个活跃连接时可省略目标。
Inputs: input (required), alias, host, port, +6 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 20 tools
Each tool has a distinct purpose: exec variants (single, batch, shell, sudo), SFTP operations (upload, download, list, etc.), session management (shell_*), and server configuration. Even similar-sounding tools like exec and exec_shell are clearly differentiated by interactive vs sudo mode.
All tool names follow a consistent verb_noun pattern: exec_*, sftp_*, shell_*, list_*, etc. No mixing of styles (all lowercase with underscores). Even standalone verbs like 'connect' and 'disconnect' fit the pattern.
Twenty tools is appropriate for an SSH management server. It covers connection, command execution, file transfer, session control, server configuration, and audit, without excessive redundancy.
The tool surface covers the full lifecycle of SSH operations: connect/disconnect, various execution modes, SFTP file management, persistent shell sessions, server config storage, health checks, and logs. Missing features like port forwarding are not core to typical SSH workflows.
Maintenance
Related MCP Connectors
Secure MCP server for exploring incwo CRM data, documents, and email workflows.
Secure and manage MCP servers through the Speakeasy AI Control Plane from your agent.
Termalin's hosted MCP server. Claude, ChatGPT or any MCP client runs commands, moves files over SFTP, queries databases and reads server metrics and monitoring alerts on your servers, keylessly through Termalin Connectors: no SSH key is handed over and no inbound port is opened. Per-host command policy and an audit log. Needs a termal.in Pro or Team account (new accounts start with a 14-day Pro trial).
Linux server administration over OAuth MCP: shell, Docker, systemd, files and monitoring.
Related MCP Servers
- AlicenseBqualityDmaintenanceA server that enables remote command execution over SSH through the Model Context Protocol (MCP), supporting both password and private key authentication.19 npm2MIT
- FlicenseAqualityDmaintenanceA server based on the MCP framework that provides remote server management capabilities through SSH, supporting features like connection pooling, file transfers, and remote command execution.7-
- AlicenseAqualityDmaintenanceMCP server for managing remote servers via SSH, enabling command execution, file transfer, rsync, tunnels, health checks, backups, and database operations.172,541 npm1MIT
- AlicenseAqualityDmaintenanceAn MCP server for SSH/SCP operations with passwordless authentication, enabling remote command execution, file transfer, and session management.1917 npm1MIT