Enables AI assistants to securely execute remote SSH commands
ssh-mcp-server
SSH-based MCP (Model Context Protocol) server that allows remote execution of SSH commands via the MCP protocol.
Project Overview
ssh-mcp-server is a bridging tool that enables AI assistants and other applications supporting the MCP protocol to execute remote SSH commands through a standardized interface. This allows AI assistants to safely operate remote servers, execute commands, and retrieve results without directly exposing SSH credentials to AI models.
Key Features
- Secure Connections: Supports multiple secure SSH connection methods, including password authentication and private key authentication (with passphrase support)
- Command Security Control: Precisely control the range of allowed commands through flexible blacklist and whitelist mechanisms to prevent dangerous operations
- Standardized Interface: Complies with MCP protocol specifications for seamless integration with AI assistants supporting the protocol
- File Transfer: Supports bidirectional file transfers, uploading local files to servers or downloading files from servers
- Credential Isolation: SSH credentials are managed entirely locally and never exposed to AI models, enhancing security
- Ready to Use: Can be run directly using NPX without global installation, making it convenient and quick to deploy
- Environment Variables: Support for credentials via environment variables for secure CI/CD integration
- Batch Execution: Execute multiple commands in sequence with a single tool call
Tools List
| Tool | Description |
|---|---|
| execute-command | Execute SSH commands with optional cwd and sudo support |
| execute-batch | Execute multiple commands in sequence with a single call |
| read-file | Read file contents from remote server with line range support |
| write-file | Write content to files on remote server with append mode |
| upload | Upload local files to remote server via SFTP |
| download | Download files from remote server via SFTP |
| test-connection | Test SSH connectivity and return server info |
| get-status | Get comprehensive system status (CPU, memory, disk, OS, processes) |
| check-port | Check if ports are open/listening on remote server |
| list-servers | List all configured SSH connections |
Usage
MCP Configuration Examples
Important: In MCP configuration files, each command line argument and its value must be separate elements in the
argsarray. Do NOT combine them with spaces. For example, use"--host", "192.168.1.1"instead of"--host 192.168.1.1".
Command Line Options
Options:
-h, --host SSH server host address
-p, --port SSH server port
-u, --username SSH username
-w, --password SSH password
-k, --privateKey SSH private key file path
-P, --passphrase Private key passphrase (if any)
-W, --whitelist Command whitelist, comma-separated regular expressions
-B, --blacklist Command blacklist, comma-separated regular expressions
-s, --socksProxy SOCKS proxy server address (e.g., socks://user:password@host:port)
-t, --timeout Default command timeout in milliseconds (default: 30000)
Environment Variables (alternative to CLI options):
SSH_HOST SSH server host address
SSH_PORT SSH server port (default: 22)
SSH_USERNAME SSH username
SSH_PASSWORD SSH password
SSH_PRIVATE_KEY SSH private key file path
SSH_PASSPHRASE Private key passphrase
SSH_WHITELIST Command whitelist
SSH_BLACKLIST Command blacklist
SSH_SOCKS_PROXY SOCKS proxy server address
SSH_TIMEOUT Default command timeout in milliseconds
Using Password
{
"mcpServers": {
"ssh-mcp-server": {
"command": "npx",
"args": [
"-y",
"ssh-mcp-server",
"--host", "192.168.1.1",
"--port", "22",
"--username", "root",
"--password", "pwd123456"
]
}
}
}
Using Private Key
{
"mcpServers": {
"ssh-mcp-server": {
"command": "npx",
"args": [
"-y",
"ssh-mcp-server",
"--host", "192.168.1.1",
"--port", "22",
"--username", "root",
"--privateKey", "~/.ssh/id_rsa"
]
}
}
}
Using Private Key with Passphrase
{
"mcpServers": {
"ssh-mcp-server": {
"command": "npx",
"args": [
"-y",
"ssh-mcp-server",
"--host", "192.168.1.1",
"--port", "22",
"--username", "root",
"--privateKey", "~/.ssh/id_rsa",
"--passphrase", "pwd123456"
]
}
}
}
Using SOCKS Proxy
{
"mcpServers": {
"ssh-mcp-server": {
"command": "npx",
"args": [
"-y",
"ssh-mcp-server",
"--host", "192.168.1.1",
"--port", "22",
"--username", "root",
"--password", "pwd123456",
"--socksProxy", "socks://usern
Tools (10)
execute-commandExecute SSH commands with optional cwd and sudo supportexecute-batchExecute multiple commands in sequence with a single callread-fileRead file contents from remote server with line range supportwrite-fileWrite content to files on remote server with append modeuploadUpload local files to remote server via SFTPdownloadDownload files from remote server via SFTPtest-connectionTest SSH connectivity and return server infoget-statusGet comprehensive system status (CPU, memory, disk, OS, processes)check-portCheck if ports are open/listening on remote serverlist-serversList all configured SSH connectionsEnvironment Variables
SSH_HOSTSSH server host addressSSH_PORTSSH server port (default: 22)SSH_USERNAMESSH usernameSSH_PASSWORDSSH passwordSSH_PRIVATE_KEYSSH private key file pathSSH_PASSPHRASEPrivate key passphraseSSH_WHITELISTCommand whitelistSSH_BLACKLISTCommand blacklistSSH_SOCKS_PROXYSOCKS proxy server addressSSH_TIMEOUTDefault command timeout in millisecondsConfiguration
{
"mcpServers": {
"ssh-mcp-server": {
"command": "npx",
"args": [
"-y",
"ssh-mcp-server",
"--host", "192.168.1.1",
"--port", "22",
"--username", "root",
"--password", "pwd123456"
]
}
}
}