convez.ai
MCP ServerDevOps & InfraestruturaIntermediário
ZuhaadRathore

SSH MCP — Conexão Persistente com Servidores Remotos

ZuhaadRathore/ssh-mcp

Controle servidores remotos via SSH direto do Claude com sessões persistentes

Ver no GitHub
InicialPluginScore · de 0 a 100

Servidor MCP que oferece ao Claude uma conexão SSH persistente com máquinas remotas. Permite executar comandos, editar arquivos, gerenciar jobs em background e alternar entre perfis de servidor — tudo via chat do cliente de IA.

Instalação

$npx convez-ai ZuhaadRathore/ssh-mcp

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
0
Forks
0
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
1

Casos de uso

  • Executar comandos remotos via IA
  • Editar arquivos em servidores via SFTP
  • Gerenciar múltiplos perfis de servidor
  • Automatizar tarefas DevOps com persistência de sessão
  • Monitorar processos e recursos remotos

Veredito

Ferramenta sólida e bem estruturada para integração SSH com Claude, com suporte robusto a múltiplos perfis, SFTP e jobs persistentes. Recomendada para quem precisa automatizar operações em servidores via IA, com documentação clara e setup flexível.

README

A tradução para o português deste README ainda está na fila.

ssh-mcp

npm Node.js License: MIT

MCP server that gives Claude Code and Codex a persistent SSH connection to a remote machine. Run commands, edit files, manage background jobs, and switch between server profiles — all from your AI client.


Quickstart

Claude Code

claude mcp add-json -s user ssh-remote '{
  "type": "stdio",
  "command": "npx",
  "args": ["-y", "@zuhaadrathore/ssh-mcp"]
}'

Codex — add to ~/.codex/config.toml:

[mcp_servers.ssh_remote]
command = "npx"
args = ["-y", "@zuhaadrathore/ssh-mcp"]

Then, in your AI client's chat window (not a terminal), type a plain-English message describing the server you want to add — the AI turns it into a tool call for you. For example, type this into Claude Code or Codex chat:

Add an SSH server: host=your.server.com user=youruser key=~/.ssh/id_rsa

(Swap in your real host/user/key path.) Anything similarly worded works — the model maps it to the ssh_server_add tool.

Alternatively, skip the chat step and bootstrap a server automatically on launch using env vars — see Environment variables below for what they do and where to set them.


What you get

Once connected, your AI client can:

  • Run commands in named persistent shell sessions (each session keeps its own cwd and env)
  • Read, write, edit, move, delete, and tail remote files via SFTP
  • Launch and monitor background jobs
  • Run sudo commands via a short-lived confirmation token flow
  • Switch between multiple server profiles at runtime without restarting
  • Discover SSH hosts from ~/.ssh/config and known_hosts
  • Inspect processes, disk usage, and environment variables

Server profiles

Profiles are stored in ~/.ssh-mcp/servers.json. Manage them by typing plain-English requests into your AI client's chat — not by running shell commands:

List my SSH servers
Add server prod: host=prod.example.com user=deploy key=~/.ssh/prod_key
Switch to prod
Remove the staging server

Or use env vars for a one-off bootstrap (profile is created on first launch, then managed in the profile file).

These aren't shell-exported variables — they go in the "env" block of the MCP server config you registered in Quickstart. For Claude Code, that means re-running claude mcp add-json with an "env" key added:

claude mcp add-json -s user ssh-remote '{
  "type": "stdio",
  "command": "npx",
  "args": ["-y", "@zuhaadrathore/ssh-mcp"],
  "env": {
    "SSH_HOST": "your.server.com",
    "SSH_USER": "youruser",
    "SSH_KEY_PATH": "/path/to/key",
    "SSH_PORT": "22",
    "SSH_PROFILE": "default"
  }
}'

For Codex, add the same keys under env = { ... } in the [mcp_servers.ssh_remote] block in ~/.codex/config.toml:

[mcp_servers.ssh_remote]
command = "npx"
args = ["-y", "@zuhaadrathore/ssh-mcp"]
env = { SSH_HOST = "your.server.com", SSH_USER = "youruser", SSH_KEY_PATH = "/path/to/key" }

SSH_KEY_PATH or SSH_PASSWORD is required; SSH_PORT and SSH_PROFILE are optional. This config is only read once — after the profile exists in ~/.ssh-mcp/servers.json, edit it through the AI chat instead.


Named sessions

Each ssh_exec call runs in a named shell that persists across calls:

Run `cd /app && npm run dev` in session "server"
Run `npm test` in session "tests"

Sessions are independent and keep their working directory between commands. Switching profiles resets sessions to the new server.


Tools reference

Execution

ToolDescription
ssh_execRun a command in a named persistent shell session
ssh_exec_bgStart a long-running command in the background
ssh_exec_sudoRun a command via sudo -n with a confirmation token

Background jobs

ToolDescription
ssh_job_listList tracked jobs and their status
ssh_job_outputGet output and status of a background job
ssh_job_killKill a running background job

Files

ToolDescription
ssh_read_fileRead a remote file (supports offset/limit for partial reads)
ssh_write_fileWrite file content via SFTP (auto-creates directories)
ssh_edit_fileExact string replacement with optional SHA256 precondition and dry-run preview
ssh_deleteDelete files or directories
ssh_moveMove or rename files and directories
ssh_chmodChange file permissions
ssh_tailTail the last N lines of a file

Directory and search

ToolDescription
ssh_list_dirList a directory (long: true for metadata)
ssh_statStat a file or directory
ssh_findFind files by name and/or content

System

ToolDescription
ssh_psList running processes
ssh_dfShow disk usage
ssh_envDump environment variables for a shell session

Host discovery

ToolDescription
ssh_host_listList hosts from ~/.ssh/config and known_hosts
ssh_host_infoShow SSH config details for a host alias
ssh_host_checkGenerate a connectivity check command

Connection and profiles

ToolDescription
ssh_statusShow active profile, connection state, and session snapshots
ssh_reconnectReconnect a session or the full connection
ssh_server_listList configured profiles
ssh_server_addAdd or update a profile
ssh_server_useSwitch active profile and reconnect
ssh_server_removeRemove a profile

Environment variables

VariableDescription
SSH_HOSTBootstrap host (used if profile file is empty)
SSH_USERBootstrap username
SSH_PASSWORDBootstrap password auth
SSH_KEY_PATHBootstrap key auth
SSH_PORTBootstrap port (default 22)
SSH_PROFILEBootstrap profile name (default default)
SSH_SERVERS_FILEOverride profile file path
SSH_POLICY_FILEOverride policy file path (default ~/.ssh-mcp/policy.json)
SSH_AUDIT_FILEOverride audit log path (default ~/.ssh-mcp/audit.log.jsonl)

Security policy

Optional. If no policy file exists, all tools work normally. When present, the JSON policy restricts commands, paths, and writes — globally or per profile.

~/.ssh-mcp/policy.json example:

{
  "deniedCommands": ["rm\\s+-rf\\s+/"],
  "allowedRemotePaths": ["/srv/app", "/var/log"],
  "profiles": {
    "prod": {
      "readOnlyMode": true,
      "allowedCommands": ["^(ls|cat|tail|grep|df|ps)\\b"]
    }
  }
}

Audit log

All command and file operations are appended as JSONL to ~/.ssh-mcp/audit.log.jsonl. Command entries store a SHA256 hash rather than raw text.


License

MIT

Ver o original no GitHub

Bom para

Relacionados