mcp-ssh-tool
The mcp-ssh-tool server enables autonomous SSH-based remote system management through natural language commands via MCP clients (e.g., GitHub Copilot, VS Code).
SSH Session Management
Open, close, list, and ping SSH sessions
Authenticate via password, SSH key (inline, path, or auto-discovery), or SSH agent
List and resolve hosts/aliases from
~/.ssh/configConnection pooling with TTL and LRU eviction
Command Execution
Run arbitrary commands (
proc_exec) with optional working directory, environment variables, and timeoutExecute commands with sudo privileges (
proc_sudo)
File System Operations (via SFTP or shell fallback)
Read, write, stat, list, create directories, remove, and rename/move files and directories
Configuration & Automation
Ensure packages are installed or removed (
ensure_package)Ensure services are started, stopped, restarted, enabled, or disabled (
ensure_service)Add or remove specific lines in config files (
ensure_lines_in_file)Apply unified diff patches to remote files (
patch_apply)
System Information & Metrics
Detect OS, distro, package manager, init system, and shell (
os_detect)Retrieve server metrics in JSON or Prometheus format
Additional Highlights
Automatic fallback to shell-based file ops for BusyBox/Dropbear (embedded) systems without SFTP
Sensitive data redaction in logs and configurable host key verification
Supports Linux, macOS, and Windows targets
Enables natural language SSH automation within GitHub Copilot, allowing for autonomous file operations and command execution on remote servers.
Supports the remote installation and management of the htop system monitoring tool via automated package management commands.
Provides comprehensive management of Linux-based systems, including process execution with sudo privileges, service control, and file system operations.
Facilitates SSH connectivity and remote command execution on macOS environments using POSIX shell wrappers.
Allows for the remote management of NGINX web servers, including configuration file editing and service state control.
Enables automated package management and system administration specifically tailored for Ubuntu server environments.
mcp-ssh-tool
Production-grade MCP SSH automation for operators, developers, and AI clients. mcp-ssh-tool opens persistent SSH sessions and exposes safe, structured tools for command execution, file operations, transfers, tunnels, package/service management, metrics, resources, and guided prompts.
v2 is secure by default: strict host-key verification is on, root login is off, raw sudo is policy-gated, destructive commands and filesystem mutations are denied unless policy allows them, and remote HTTP starts on loopback only unless bearer auth and allowed origins are configured.
Why This Server
Trust: central policy engine, structured audit events, redacted logs, strict host keys, and machine-readable errors.
MCP quality: stdio for local clients, Streamable HTTP for remote clients, legacy SSE only behind an explicit compatibility flag.
AI-friendly tools: stable output schemas,
structuredContent, annotations for read-only/destructive/idempotent behavior, resources, and curated prompts.Operations: session TTL/eviction, command timeouts, transfer checksum verification, real SSH forwarding, Prometheus metrics, and OpenTelemetry hooks.
Portability: SFTP first, POSIX/BusyBox-aware shell fallbacks for basic file operations, and explicit support boundaries.
Quick Start
Run without installing:
pnpm dlx mcp-ssh-tool --versionOr install globally:
pnpm add --global mcp-ssh-toolAdd a stdio MCP server to your client:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool",
"args": []
}
}
}Use it from your MCP client:
Open a safe SSH session to prod-1 as deploy, inspect host capabilities, then show disk usage.Requirements
Node.js
22.22.2+or24.15.0+(LTS only)SSH access to target hosts
A populated
known_hostsfile for strict host verification, or an explicit per-session host-key policy
Transports
Mode | Command | Use When |
stdio |
| Local desktop clients such as ChatGPT, Claude Desktop, VS Code, Cursor, or Codex. |
Streamable HTTP |
| Remote MCP clients, reverse proxies, or Inspector sessions. |
legacy SSE |
| Temporary v1 compatibility only. Prefer Streamable HTTP. |
Non-loopback HTTP startup is refused unless --bearer-token-file, allowed origins, and SSH_MCP_HTTP_PUBLIC_URL are configured.
No-Custody Remote Agent Mode
For public ChatGPT connector deployments, enable the remote-agent control plane instead of asking users for SSH credentials:
SSHAUTOMATOR_REMOTE_AGENT_CONTROL_PLANE=true \
PUBLIC_BASE_URL=https://sshautomator.example.com \
MCP_RESOURCE_URL=https://sshautomator.example.com/mcp \
mcp-ssh-tool http --host 0.0.0.0 --port 3000Remote mode adds OAuth/DCR endpoints, a protected /mcp endpoint, agent enrollment APIs, and outbound WebSocket agent connections. ChatGPT receives OAuth-scoped MCP access. The platform stores identity, policy, audit records, OAuth metadata, hashed one-time tokens, and agent public keys; it does not store user SSH private keys, SSH passwords, root passwords, or cloud login credentials.
Enroll an agent on the user's own host:
npx --yes --package mcp-ssh-tool@latest mcp-ssh-agent enroll --server https://sshautomator.example.com --token <one-time-token> --alias prod-1
npx --yes --package mcp-ssh-tool@latest mcp-ssh-agent runThe agent verifies signed control-plane action envelopes, enforces local policy, executes bounded actions, signs results, and returns them over the outbound connection. See docs/ARCHITECTURE.md, docs/CHATGPT_CONNECTOR.md, and docs/AGENT_INSTALL.md.
Secure Defaults
Area | v2 Default |
Host keys |
|
Root SSH login | denied |
Raw | denied unless |
Destructive commands | denied unless |
Destructive fs operations | allowed only under policy prefixes, denied elsewhere |
Local transfer paths |
|
HTTP bind |
|
Legacy SSE | disabled |
File reads | size-limited by |
Command output | bounded by |
Transfers | bounded by |
Per-session policyMode: "explain" returns a plan/verdict without executing. Use it before mutations when an AI client needs to summarize risk.
Policy Example
Set 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"],
"localPathAllowPrefixes": ["/var/tmp/mcp-ssh-tool"],
"localPathDenyPrefixes": []
}Simple deploys can use environment overrides such as SSH_MCP_ALLOW_RAW_SUDO=true, SSH_MCP_ALLOWED_HOSTS=prod-1.example.com, SSH_MCP_PATH_ALLOW_PREFIXES=/tmp,/home/deploy, or SSH_MCP_LOCAL_PATH_ALLOW_PREFIXES=/var/tmp/mcp-ssh-tool.
Core 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
All tools return text plus stable structuredContent. Tool metadata includes titles, output schemas, and annotations that disclose read-only, destructive, idempotent, and external side-effect behavior.
Resources And Prompts
Resources:
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
Target | Status |
Linux | Full support. |
macOS/BSD | Session, process, fs, and transfer supported; package/service helpers only where tested. |
BusyBox/dropbear | Experimental for session, process, and basic fs fallbacks. |
Windows SSH targets | Experimental for session, process, fs, and transfer; no |
Client Examples
ChatGPT or Claude Desktop:
{
"mcpServers": {
"ssh-mcp": {
"command": "pnpm",
"args": ["dlx", "mcp-ssh-tool"]
}
}
}VS Code or Cursor:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool"
}
}
}MCP Inspector over HTTP:
printf '%s' 'super-secret-token' > .mcp-token
mcp-ssh-tool --transport=http --host 127.0.0.1 --port 3000 --bearer-token-file .mcp-tokenConfiguration
High-value environment variables:
Variable | Default | Purpose |
| unset | Canonical JSON policy source. |
|
|
|
|
| Known-hosts file for strict verification. |
|
| Max bytes for |
|
| Max text payload bytes accepted by |
|
| Max retained stdout/stderr bytes per command or stream. |
|
| Max retained streaming chunks before truncation metadata is returned. |
|
| Max bytes for |
|
| Default command timeout. |
|
| Streamable HTTP bind host. |
|
| Streamable HTTP port. |
|
| Max JSON request bytes accepted by Streamable HTTP. |
|
| Max concurrent Streamable HTTP/SSE MCP sessions. |
|
| Idle TTL before abandoned HTTP sessions are closed. |
| unset | Required for non-loopback HTTP to publish stable protected-resource metadata. |
|
| Trust |
| OS temp directory | Local transfer allow-list for |
|
| Tunnel bind-host allow-list. |
|
| Tunnel bind-host deny-list. |
| unset | Optional tunnel destination host allow-list. |
| unset | Tunnel destination host deny-list. |
| unset | Optional tunnel port allow-list, including ranges such as |
| unset | Tunnel port deny-list. |
| unset | Required for non-loopback HTTP. |
| loopback origins | Comma-separated allowed origins. |
Deprecated aliases STRICT_HOST_KEY_CHECKING and SSH_MCP_STRICT_HOST_KEY are still accepted for one v2 compatibility cycle. Prefer SSH_MCP_HOST_KEY_POLICY.
Development
Use the exact local runtime from .nvmrc / .node-version, then run:
pnpm install --frozen-lockfile
pnpm run checkLive SSH suites are opt-in:
RUN_SSH_INTEGRATION=1 pnpm run test:integration
RUN_SSH_E2E=1 pnpm run test:e2eLocal quality gates are layered:
pre-commit: formats staged files and lints staged TypeScript onlypre-push: runspnpm run check:pushtask hooks: runs tracked pnpm hooks plus.pre-commit-config.yamlhooks whenpre-commitis installedmanual/full parity:
task ciorpnpm run check
CI/CD Ownership
The personal repository https://github.com/oaslananka/mcp-ssh-tool is the source repository. The organization repository https://github.com/oaslananka-lab/mcp-ssh-tool is the GitHub Actions, CI/CD, release, security, and provenance boundary.
Automatic CI/CD, supply-chain security checks, trusted npm publishing, MCP Registry publishing, GitHub Releases, Docker image validation, SBOMs, attestations, and release decisions run only from the org repository. Personal-repo Actions are intentionally not required gates.
The two repositories must stay content-identical for main, release tags, releases, labels, milestones, and active collaboration state. Org release-generated refs are backfilled to the personal source repository.
The npm package repository.url intentionally points at the org automation repository so npm provenance can verify that the published artifact came from the same GitHub Actions repository that built it. The MCP Registry server name remains io.github.oaslananka/mcp-ssh-tool because it is already published and changing it would break existing users.
See docs/ci-cd-topology.md for mirror, release, dry-run, and manual fallback guidance.
Documentation
License
MIT License. See 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.