SSH MCP Server

$npx -y ssh-mcp-server
README.md

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 args array. 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 support
execute-batchExecute multiple commands in sequence with a single call
read-fileRead file contents from remote server with line range support
write-fileWrite content to files on remote server with append mode
uploadUpload local files to remote server via SFTP
downloadDownload files from remote server via SFTP
test-connectionTest SSH connectivity and return server info
get-statusGet comprehensive system status (CPU, memory, disk, OS, processes)
check-portCheck if ports are open/listening on remote server
list-serversList all configured SSH connections

Environment Variables

SSH_HOSTSSH server host address
SSH_PORTSSH server port (default: 22)
SSH_USERNAMESSH username
SSH_PASSWORDSSH password
SSH_PRIVATE_KEYSSH private key file path
SSH_PASSPHRASEPrivate key passphrase
SSH_WHITELISTCommand whitelist
SSH_BLACKLISTCommand blacklist
SSH_SOCKS_PROXYSOCKS proxy server address
SSH_TIMEOUTDefault command timeout in milliseconds

Configuration

claude_desktop_config.json
{
  "mcpServers": {
    "ssh-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "ssh-mcp-server",
        "--host", "192.168.1.1",
        "--port", "22",
        "--username", "root",
        "--password", "pwd123456"
      ]
    }
  }
}

Try it

Check the current CPU and memory usage on the remote server.
Read the last 50 lines of the nginx access log at /var/log/nginx/access.log.
Upload my local config.json file to the /home/user/app directory on the server.
Check if port 8080 is currently listening on the remote host.
Execute a batch of commands to update the system and restart the docker service.

Frequently Asked Questions

How do I install SSH MCP Server?

Install SSH MCP Server by running: npx -y ssh-mcp-server

What MCP clients work with SSH MCP Server?

SSH MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Use SSH MCP Server with Conare

Manage MCP servers visually, upload persistent context, and never start from zero with Claude Code & Codex.

Try Free