Skip to main content

MCP server for remote VPS management via SSH key authentication — designed for Claude Code

Project description

ssh-vps-mcp

MCP server for remote VPS management via SSH key authentication — built for Claude Code.

Manage files and run commands on your remote VPS directly from Claude Code using the Model Context Protocol (MCP). Only SSH key authentication is supported — passwords are explicitly rejected.


Features

  • SSH key-only auth — RSA, Ed25519, ECDSA, DSS. No passwords.
  • File operations — read, write, append, delete, rename, stat
  • Directory operations — list, create, delete (recursive)
  • Shell execution — run any command with stdout/stderr/exit code capture
  • Connection checkvps_ping tool with server info
  • Secure — checks key file permissions (must be 600), no SSH agent fallback, no ~/.ssh key scanning

Installation

pip install ssh-vps-mcp

Or install from source:

git clone https://github.com/aldirrss/ssh-vps-mcp
cd ssh-vps-mcp
pip install .

Verify installation:

ssh-vps-mcp --version

Usage with Claude Code

1. Configure in Claude Code

Add to your Claude Code MCP config. The config file is at:

  • Global: ~/.claude.json
  • Project-level: .claude/settings.json (in your project root)
{
  "mcpServers": {
    "vps": {
      "command": "ssh-vps-mcp",
      "args": [
        "--host", "YOUR_VPS_IP_OR_HOSTNAME",
        "--user", "root",
        "--private-key-path", "~/.ssh/id_rsa"
      ]
    }
  }
}

2. Or add via Claude Code CLI

claude mcp add vps -- ssh-vps-mcp \
  --host YOUR_VPS_IP \
  --user root \
  --private-key-path ~/.ssh/id_rsa

3. Start Claude Code

claude

You'll see the VPS MCP connect on startup. Then ask Claude to manage your server:

> Can you check what's in /var/log/nginx/ on the VPS?
> Deploy this nginx config to /etc/nginx/sites-available/myapp
> Run: systemctl restart nginx

Authentication Options

Option A: Private key file (recommended)

{
  "mcpServers": {
    "vps": {
      "command": "ssh-vps-mcp",
      "args": [
        "--host", "217.15.166.73",
        "--user", "root",
        "--private-key-path", "~/.ssh/id_rsa"
      ]
    }
  }
}

Key file must have chmod 600 permissions or the server will refuse to start.

Option B: Passphrase-protected key

{
  "args": [
    "--host", "myserver.com",
    "--user", "deploy",
    "--private-key-path", "~/.ssh/id_ed25519",
    "--key-passphrase", "your-passphrase"
  ]
}

Option C: Key content from environment variable

Useful for CI/CD or when storing keys in a secrets manager:

{
  "mcpServers": {
    "vps": {
      "command": "ssh-vps-mcp",
      "args": [
        "--host", "myserver.com",
        "--user", "deploy",
        "--private-key-content", "${SSH_PRIVATE_KEY}"
      ]
    }
  }
}

Set SSH_PRIVATE_KEY environment variable to your full PEM content.

Option D: Custom SSH port

{
  "args": [
    "--host", "myserver.com",
    "--user", "root",
    "--port", "2222",
    "--private-key-path", "~/.ssh/id_rsa"
  ]
}

Available MCP Tools

Tool Description
vps_ping Test connection, get server info (uname, uptime, whoami)
vps_exec Run a shell command, returns exit_code + stdout + stderr
vps_read_file Read a file's contents
vps_write_file Write (create/overwrite) a file
vps_append_file Append text to an existing file
vps_delete_file Delete a file
vps_list_dir List files in a directory
vps_stat Get file/directory metadata
vps_mkdir Create directory (with parents)
vps_delete_dir Delete directory (recursive=true for non-empty)
vps_rename Rename or move file/directory

Multiple VPS Servers

You can configure multiple VPS servers in one config:

{
  "mcpServers": {
    "vps-production": {
      "command": "ssh-vps-mcp",
      "args": ["--host", "prod.example.com", "--user", "root", "--private-key-path", "~/.ssh/prod_rsa"]
    },
    "vps-staging": {
      "command": "ssh-vps-mcp",
      "args": ["--host", "staging.example.com", "--user", "deploy", "--private-key-path", "~/.ssh/staging_rsa"]
    }
  }
}

CLI Reference

ssh-vps-mcp --help

Arguments:
  --host HOST                     VPS hostname or IP (required)
  --user USER                     SSH username (required)
  --port PORT                     SSH port (default: 22)
  --private-key-path PATH         Path to private key file (chmod 600)
  --private-key-content PEM       Raw PEM content of private key
  --key-passphrase PHRASE         Passphrase for encrypted key
  --timeout SECONDS               Connection timeout (default: 15)
  --version                       Show version

Security Notes

  • No password auth — the server will error if no key is provided.
  • Key file permission check — files with group/world read permissions (not 600) are rejected.
  • No SSH agent — won't silently use your ssh-agent keys.
  • No ~/.ssh scanning — only uses the key you explicitly provide.
  • AutoAddPolicy — host keys are auto-accepted (suitable for known VPS IPs; you can restrict this for production).

Requirements

  • Python 3.10+
  • SSH key pair with public key already added to ~/.ssh/authorized_keys on your VPS

License

MIT — Lema Core Technologies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssh_vps_mcp-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssh_vps_mcp-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file ssh_vps_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: ssh_vps_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for ssh_vps_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a2596d5b161f30ae13dd5ffd562f9ff99d288583ea5dede9d77d073e530a06cc
MD5 6ae158dfb977c360c73f22a0b836d270
BLAKE2b-256 24cdce6238af623df83ac266fa21915a34d7b43d1625a9dc4e48d61d00d552c4

See more details on using hashes here.

File details

Details for the file ssh_vps_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ssh_vps_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for ssh_vps_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d377fa9745f9eae764ec0171d8a0e3a2e4f3ff66068f738238db80abd74a6030
MD5 f50136806dfa467573c3b8352cce67c1
BLAKE2b-256 1e5774a8532ef7c2cd7814e5622ebb7c0869edbb133d1f2fa025f7131c48b5b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page