mcp-ssh-tool
mcp-ssh-tool
Produktionsreife MCP-SSH-Automatisierung für Operatoren, Entwickler und KI-Clients. mcp-ssh-tool öffnet persistente SSH-Sitzungen und stellt sichere, strukturierte Tools für die Befehlsausführung, Dateivorgänge, Übertragungen, Tunnel, Paket-/Dienstverwaltung, Metriken, Ressourcen und geführte Prompts bereit.
v2 ist standardmäßig sicher: Strenge Host-Key-Überprüfung ist aktiviert, Root-Login ist deaktiviert, rohes sudo ist richtlinienbasiert eingeschränkt, destruktive Befehle und Dateisystemänderungen sind untersagt, sofern die Richtlinie dies nicht zulässt, und Remote-HTTP startet nur auf dem Loopback-Interface, es sei denn, Bearer-Authentifizierung und erlaubte Ursprünge sind konfiguriert.
Warum dieser Server
Vertrauen: Zentrale Richtlinien-Engine, strukturierte Audit-Ereignisse, bereinigte Protokolle, strenge Host-Keys und maschinenlesbare Fehler.
MCP-Qualität: stdio für lokale Clients, Streamable HTTP für Remote-Clients, Legacy-SSE nur hinter einem expliziten Kompatibilitäts-Flag.
KI-freundliche Tools: Stabile Ausgabeschemata,
structuredContent, Annotationen für schreibgeschütztes/destruktives/idempotentes Verhalten, Ressourcen und kuratierte Prompts.Betrieb: Sitzungs-TTL/Eviction, Befehls-Timeouts, Prüfsummenüberprüfung bei Übertragungen, echtes SSH-Forwarding, Prometheus-Metriken und OpenTelemetry-Hooks.
Portabilität: SFTP zuerst, POSIX/BusyBox-fähige Shell-Fallbacks für grundlegende Dateivorgänge und explizite Support-Grenzen.
Schnellstart
Ausführen ohne Installation:
npx -y mcp-ssh-tool --versionOder global installieren:
npm install -g mcp-ssh-toolFügen Sie Ihrem Client einen stdio-MCP-Server hinzu:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool",
"args": []
}
}
}Verwenden Sie ihn von Ihrem MCP-Client aus:
Open a safe SSH session to prod-1 as deploy, inspect host capabilities, then show disk usage.Anforderungen
Node.js
22.22.2+oder24.14.1+(nur LTS)SSH-Zugriff auf Ziel-Hosts
Eine gefüllte
known_hosts-Datei für die strenge Host-Überprüfung oder eine explizite Host-Key-Richtlinie pro Sitzung
Transporte
Modus | Befehl | Verwendung bei |
stdio |
| Lokale Desktop-Clients wie ChatGPT, Claude Desktop, VS Code, Cursor oder Codex. |
Streamable HTTP |
| Remote-MCP-Clients, Reverse-Proxys oder Inspector-Sitzungen. |
Legacy SSE |
| Nur für temporäre v1-Kompatibilität. Bevorzugen Sie Streamable HTTP. |
Der Start von HTTP außerhalb des Loopbacks wird verweigert, sofern nicht sowohl --bearer-token-file als auch erlaubte Ursprünge konfiguriert sind.
Sichere Standardeinstellungen
Bereich | v2-Standard |
Host-Keys |
|
Root-SSH-Login | verweigert |
Rohes | verweigert, sofern nicht |
Destruktive Befehle | verweigert, sofern nicht |
Destruktive FS-Vorgänge | nur unter Richtlinien-Präfixen erlaubt, sonst verweigert |
HTTP-Bindung |
|
Legacy SSE | deaktiviert |
Dateilesevorgänge | größenbegrenzt durch |
Der Modus policyMode: "explain" pro Sitzung gibt einen Plan/ein Urteil zurück, ohne es auszuführen. Verwenden Sie dies vor Änderungen, wenn ein KI-Client das Risiko zusammenfassen muss.
Richtlinienbeispiel
Setzen Sie SSH_MCP_POLICY_FILE=/etc/mcp-ssh-tool/policy.json:
{
"mode": "enforce",
"allowRootLogin": false,
"allowRawSudo": false,
"allowDestructiveCommands": false,
"allowDestructiveFs": false,
"allowedHosts": ["^prod-[0-9]+\\.example\\.com$"],
"commandAllow": ["^(uname|df|uptime|systemctl status)\\b"],
"commandDeny": ["rm\\s+-rf\\s+/", "shutdown", "reboot"],
"pathAllowPrefixes": ["/tmp", "/var/tmp", "/home/deploy"],
"pathDenyPrefixes": ["/etc/shadow", "/etc/sudoers", "/boot", "/dev", "/proc"]
}Einfache Bereitstellungen können Umgebungsvariablen-Überschreibungen wie SSH_MCP_ALLOW_RAW_SUDO=true, SSH_MCP_ALLOWED_HOSTS=prod-1.example.com oder SSH_MCP_PATH_ALLOW_PREFIXES=/tmp,/home/deploy verwenden.
Kern-Tools
ssh_open_session,ssh_close_session,ssh_list_sessions,ssh_ping,ssh_list_configured_hosts,ssh_resolve_hostproc_exec,proc_sudo,proc_exec_streamfs_read,fs_write,fs_list,fs_stat,fs_mkdirp,fs_rmrf,fs_renamefile_upload,file_downloadensure_package,ensure_service,ensure_lines_in_file,patch_applyos_detect,get_metricstunnel_local_forward,tunnel_remote_forward,tunnel_list,tunnel_close
Alle Tools geben Text sowie stabiles structuredContent zurück. Tool-Metadaten enthalten Titel, Ausgabeschemata und Annotationen, die schreibgeschütztes, destruktives, idempotentes und externes Nebenwirkungsverhalten offenlegen.
Ressourcen und Prompts
Ressourcen:
mcp-ssh-tool://sessions/activemcp-ssh-tool://metrics/jsonmcp-ssh-tool://metrics/prometheusmcp-ssh-tool://ssh-config/hostsmcp-ssh-tool://policy/effectivemcp-ssh-tool://audit/recentmcp-ssh-tool://capabilities/support-matrix
Prompts:
safe-connectinspect-host-capabilitiesplan-mutationmanaged-config-change
Support-Matrix
Ziel | Status |
Linux | Volle Unterstützung. |
macOS/BSD | Sitzung, Prozess, FS und Übertragung unterstützt; Paket-/Dienst-Helfer nur dort, wo getestet. |
BusyBox/dropbear | Experimentell für Sitzung, Prozess und grundlegende FS-Fallbacks. |
Windows SSH-Ziele | Experimentell für Sitzung, Prozess, FS und Übertragung; kein |
Client-Beispiele
ChatGPT oder Claude Desktop:
{
"mcpServers": {
"ssh-mcp": {
"command": "npx",
"args": ["-y", "mcp-ssh-tool"]
}
}
}VS Code oder Cursor:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool"
}
}
}MCP Inspector über HTTP:
printf '%s' 'super-secret-token' > .mcp-token
mcp-ssh-tool --transport=http --host 127.0.0.1 --port 3000 --bearer-token-file .mcp-tokenKonfiguration
Wichtige Umgebungsvariablen:
Variable | Standard | Zweck |
| nicht gesetzt | Kanonische JSON-Richtlinienquelle. |
|
|
|
|
| Known-hosts-Datei für strenge Überprüfung. |
|
| Maximale Bytes für |
|
| Standard-Befehls-Timeout. |
|
| Streamable HTTP-Bindungs-Host. |
|
| Streamable HTTP-Port. |
| nicht gesetzt | Erforderlich für HTTP außerhalb des Loopbacks. |
| Loopback-Ursprünge | Kommagetrennte erlaubte Ursprünge. |
Die veralteten Aliase STRICT_HOST_KEY_CHECKING und SSH_MCP_STRICT_HOST_KEY werden für einen v2-Kompatibilitätszyklus noch akzeptiert. Bevorzugen Sie SSH_MCP_HOST_KEY_POLICY.
Entwicklung
Verwenden Sie die exakte lokale Laufzeit aus .nvmrc / .node-version und führen Sie dann aus:
npm ci
npm run checkLive-SSH-Suiten sind optional:
RUN_SSH_INTEGRATION=1 npm run test:integration
RUN_SSH_E2E=1 npm run test:e2eLokale Qualitäts-Gates sind geschichtet:
pre-commit: Formatiert gestagte Dateien und lintet nur gestagtes TypeScriptpre-push: Führtnpm run check:pushaustask hooks: Führt verfolgte npm-Hooks plus.pre-commit-config.yaml-Hooks aus, wennpre-commitinstalliert istmanuelle/vollständige Parität:
task ciodernpm run check
CI/CD-Eigentümerschaft
Das persönliche Repository https://github.com/oaslananka/mcp-ssh-tool ist das kanonische Quell-Repository. Automatische CI/CD, Supply-Chain-Sicherheitsprüfungen, vertrauenswürdiges npm-Publishing und MCP-Registry-Publishing laufen nur von https://github.com/oaslananka-lab/mcp-ssh-tool. Das Organisations-Repository zieht aus der kanonischen Quelle; Push- und Publish-Workflows des persönlichen Repositorys sind deaktiviert.
Die repository.url des npm-Pakets zeigt absichtlich auf das Organisations-Repository, damit die npm-Provenienz überprüfen kann, ob das veröffentlichte Artefakt aus demselben GitHub-Actions-Repository stammt, das es erstellt hat.
Siehe docs/ci-cd-topology.md für Organisations-Sync, Release-Flow und manuelle Fallback-Anleitungen.
Dokumentation
Lizenz
MIT-Lizenz. Siehe LICENSE.
Available Tools
33 toolsconnector_statusConnector StatusARead-onlyIdempotent
Use this when ChatGPT or Claude needs to understand the remote connector profile, authentication mode, and credential broker readiness without exposing secrets.
Inputs: no named parameters. Returns: Remote connector readiness without secrets
ensure_lines_in_fileEnsure Lines In FileADestructiveIdempotent
Ensures specific lines are present or absent in a file
Inputs: sessionId (required), path (required), lines (required), state, +1 more. Returns: Line management result
ensure_packageEnsure Package StateCDestructiveIdempotent
Ensures a package is installed or removed
Inputs: sessionId (required), name (required), state. Returns: Package state result
ensure_serviceEnsure Service StateBDestructiveIdempotent
Ensures a service is in the desired state
Inputs: sessionId (required), name (required), state (required). Returns: Service state result
file_downloadDownload FileARead-only
Downloads a remote file to the local machine over SFTP
Inputs: sessionId (required), remotePath (required), localPath (required). Returns: Download result with integrity details
file_uploadUpload FileBDestructive
Uploads a local file to the remote host over SFTP
Inputs: sessionId (required), localPath (required), remotePath (required). Returns: Upload result with integrity details
fs_listList Remote DirectoryCRead-onlyIdempotent
Lists directory contents
Inputs: sessionId (required), path (required), page, limit. Returns: Remote directory entries
fs_mkdirpCreate Remote DirectoriesAIdempotent
Creates directories recursively
Inputs: sessionId (required), path (required). Returns: Directory creation result
fs_readRead Remote FileBRead-onlyIdempotent
Reads a file from the remote system
Inputs: sessionId (required), path (required), encoding, maxBytes. Returns: Remote file content wrapped as structured content
fs_renameRename Remote PathBDestructive
Renames or moves a file/directory
Inputs: sessionId (required), from (required), to (required). Returns: Rename result
fs_rmrfRemove Remote Path RecursivelyADestructive
Removes files or directories recursively
Inputs: sessionId (required), path (required). Returns: Recursive remove result
fs_statStat Remote PathARead-onlyIdempotent
Gets file or directory statistics
Inputs: sessionId (required), path (required). Returns: Remote path stat result
fs_writeWrite Remote FileBDestructive
Writes data to a file on the remote system
Inputs: sessionId (required), path (required), data (required), mode. Returns: File write result
get_metricsGet Runtime MetricsARead-onlyIdempotent
Returns server metrics including session counts, command statistics, and uptime
Inputs: format. Returns: Runtime metrics
os_detectDetect Remote OSARead-onlyIdempotent
Detects operating system and environment information
Inputs: sessionId (required). Returns: Remote operating system information
patch_applyApply PatchBDestructive
Applies a patch to a file
Inputs: sessionId (required), path (required), diff (required). Returns: Patch application result
proc_execExecute Remote CommandA
Executes a non-interactive command on the remote system after policy and safety checks
Inputs: sessionId (required), command (required), cwd, env, +1 more. Returns: Remote command result
proc_exec_streamExecute Streaming CommandA
Executes a command and returns streaming output chunks
Inputs: sessionId (required), command (required), cwd, env, +1 more. Returns: Streaming command result with output chunks
proc_sudoExecute Sudo CommandADestructive
Executes a command with sudo privileges only when allowRawSudo policy permits it
Inputs: sessionId (required), command (required), cwd, timeoutMs. Returns: Remote sudo command result
ssh_close_sessionClose SSH SessionBIdempotent
Closes an SSH session
Inputs: sessionId (required). Returns: Boolean close result wrapped as structured content
ssh_host_inspectInspect SSH HostARead-only
Use this when ChatGPT or Claude needs read-only host inspection through the server-side credential broker. The user supplies only a configured host alias and selected checks; no secret material or login details are accepted.
Inputs: hostAlias (required), checks. Returns: Read-only host inspection result
ssh_hosts_listList Safe SSH Host AliasesARead-onlyIdempotent
Use this when ChatGPT or Claude needs a safe list of SSH host aliases that may be inspected through the remote connector. Sensitive login material is omitted.
Inputs: no named parameters. Returns: Redacted SSH host aliases allowed by policy
ssh_list_configured_hostsList Configured HostsARead-onlyIdempotent
Lists all hosts configured in ~/.ssh/config
Inputs: no named parameters. Returns: Configured SSH host aliases
ssh_list_sessionsList SSH SessionsARead-onlyIdempotent
Lists all active SSH sessions with their details
Inputs: no named parameters. Returns: Active SSH sessions
ssh_mutation_planPlan SSH MutationARead-onlyIdempotent
Use this when ChatGPT or Claude needs a non-executing plan for a remote SSH change. It never runs commands, writes files, uploads data, starts tunnels, or escalates privileges.
Inputs: hostAlias (required), goal (required), category. Returns: Non-executing remote mutation plan
ssh_open_sessionOpen SSH SessionB
Opens a new SSH session with authentication
Inputs: host (required), username (required), port, auth, +12 more. Returns: Session creation result or explain-mode connection plan
ssh_pingPing SSH SessionARead-onlyIdempotent
Checks if an SSH session is still alive and responsive
Inputs: sessionId (required). Returns: Session health check result
ssh_policy_explainExplain SSH PolicyARead-onlyIdempotent
Use this when ChatGPT or Claude needs to explain whether a requested SSH inspection or mutation would be allowed. This is explain-only and does not execute commands or open tunnels.
Inputs: hostAlias, action, command, path. Returns: Explain-only policy decision
ssh_resolve_hostResolve SSH HostARead-onlyIdempotent
Resolves a host alias from ~/.ssh/config to connection parameters
Inputs: hostAlias (required). Returns: Resolved SSH connection parameters
tunnel_closeClose SSH TunnelBIdempotent
Closes an active tunnel
Inputs: tunnelId (required). Returns: Tunnel close result
tunnel_listList SSH TunnelsARead-onlyIdempotent
Lists active tunnels, optionally filtered by session
Inputs: sessionId. Returns: Active tunnels
tunnel_local_forwardCreate Local SSH TunnelC
Creates a local SSH port forward
Inputs: sessionId (required), localPort (required), remoteHost (required), remotePort (required). Returns: Local tunnel information
tunnel_remote_forwardCreate Remote SSH TunnelC
Creates a remote SSH port forward
Inputs: sessionId (required), remotePort (required), localHost (required), localPort (required). Returns: Remote tunnel information
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 33 tools
Each tool targets a distinct operation or resource type (file, command, session, tunnel, package, service, inspection). There is no significant overlap; even similar tools like proc_exec and proc_exec_stream are differentiated by execution mode.
Tools are grouped by domain (fs_, proc_, tunnel_, ssh_, ensure_) with consistent patterns within groups. However, the overall naming convention mixes prefixes (fs_list vs file_download) and some tools use long phrasal names (ensure_lines_in_file).
At 33 tools, the server is heavily featured. While most tools serve a clear purpose, the count is above the typical sweet spot and includes several niche utilities (get_metrics, os_detect, ssh_mutation_plan) that could be consolidated.
The tool surface covers the full lifecycle of SSH interactions: session management, file operations, command execution, package/service management, tunneling, and safety/planning. No obvious gaps exist for a generic SSH administration server.
Maintenance
Related MCP Connectors
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
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).
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.