ssh-mcp-dynamic
The ssh-mcp-dynamic server enables secure, key-based SSH command execution on remote hosts, with support for both regular and sudo commands, configurable per-call parameters, and environment-variable-based defaults.
Execute shell commands: Run arbitrary shell commands on remote servers via SSH using the
ssh_exectool.Execute privileged commands: Run commands with
sudoprivileges using thessh_sudo_exectool, which automatically prependssudo.Connect to multiple machines: Host, user, port, and key are all specified per call — not hardcoded — so a single server instance can target many machines.
Key-based authentication: Authenticate using PEM private keys via direct file paths (with
~expansion) or pre-configured named shortcuts (e.g.prod,staging) defined inSSH_MCP_KEYS. No passwords are handled or stored.Configurable defaults: Set default values for SSH key, username (default:
root), port (default:22), and timeout (default:60000ms) via environment variables to reduce repetition.MCP client integration: Designed for use with MCP clients like Claude Desktop and Claude Code, allowing natural language prompts to invoke its tools.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ssh-mcp-dynamicrun 'uptime' on prod-web1"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ssh-mcp-dynamic
A minimal Model Context Protocol (MCP) server that lets an MCP client (e.g. Claude Desktop) run shell commands on remote hosts over SSH. The host, private key, user and port are chosen per call, so a single server instance can reach many machines.
It exposes two tools:
Tool | Description |
| Run a shell command on a remote host. |
| Run a shell command with |
Authentication is key-based only (PEM private keys). No passwords are handled or stored.
Requirements
Node.js 18+
SSH access to the target hosts with a private key
Related MCP server: acp-mcp
Install & build
npm install
npm run buildThis compiles src/index.ts to dist/index.js.
Configuration
Everything host-specific is supplied through environment variables — nothing is hardcoded in the source.
Variable | Default | Purpose |
|
| JSON object mapping key shortcuts to private-key paths. A leading |
| (none) | Shortcut or path used when a call omits |
|
| Default SSH username. |
|
| Default SSH port. |
|
| Default command/connection timeout in milliseconds. |
Example SSH_MCP_KEYS:
{
"prod": "~/keys/prod.pem",
"staging": "~/keys/staging.pem"
}With that set, a call can pass "key": "prod" instead of a full path. You can also pass a full path directly at call time without configuring any shortcut.
Tool parameters
Both tools accept:
host(required) — IP or hostname.command(required) — the shell command.key— a configured shortcut or a path to the PEM file. Required unlessSSH_MCP_DEFAULT_KEYis set.user— SSH username (defaults toSSH_MCP_DEFAULT_USER).port— SSH port (defaults toSSH_MCP_DEFAULT_PORT).timeout— timeout in ms (defaults toSSH_MCP_TIMEOUT_MS).
Use with Claude Code (CLI)
The quickest way — no clone, no manual build. Claude Code runs it on demand via npx straight from GitHub.
Minimal — no environment config at all. You provide the host, command and a full key path on every call:
claude mcp add ssh-mcp -- npx -y github:Calevi-Consulting/ssh-mcp-dynamicWith shortcuts and defaults — preconfigure your keys once so calls can use a short name (e.g. prod) and omit the user/port:
claude mcp add ssh-mcp -s user \
-e SSH_MCP_KEYS='{"prod":"~/keys/prod.pem"}' \
-e SSH_MCP_DEFAULT_KEY=prod \
-e SSH_MCP_DEFAULT_USER=ubuntu \
-- npx -y github:Calevi-Consulting/ssh-mcp-dynamicnpx clones the repo, builds it (via the prepare script) and launches the server. Once published to npm you can drop the github: prefix and use npx -y ssh-mcp-dynamic.
Prefer a local checkout? Build it once and point Claude Code at the compiled file:
git clone https://github.com/Calevi-Consulting/ssh-mcp-dynamic.git
cd ssh-mcp-dynamic && npm install && npm run build
claude mcp add ssh-mcp -s user \
-e SSH_MCP_KEYS='{"prod":"~/keys/prod.pem"}' \
-e SSH_MCP_DEFAULT_KEY=prod \
-- node "$(pwd)/dist/index.js"Scopes (-s): local (default, current project only), user (all your projects), project (saved to a versioned .mcp.json to share with your team).
Verify with claude mcp list, or /mcp inside a session. Remove with claude mcp remove ssh-mcp.
Use with Claude Desktop
Add the server to your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ssh-mcp": {
"command": "node",
"args": ["/absolute/path/to/ssh-mcp-dynamic/dist/index.js"],
"env": {
"SSH_MCP_KEYS": "{\"prod\":\"~/keys/prod.pem\",\"staging\":\"~/keys/staging.pem\"}",
"SSH_MCP_DEFAULT_KEY": "prod",
"SSH_MCP_DEFAULT_USER": "ubuntu"
}
}
}
}Restart Claude Desktop after editing the config.
Usage
Once the server is registered, you don't call the tools directly — you ask your MCP client (Claude Code / Claude Desktop) in plain language and it invokes ssh_exec / ssh_sudo_exec for you. Some example prompts:
Using ssh-mcp, run `hostname && uptime` on 10.0.0.5 with the prod key.
Check the free disk space on staging.example.com (df -h) via ssh-mcp.
On 10.0.0.5, tail the last 50 lines of /var/log/syslog with sudo.
Restart nginx on web-01.example.com with sudo, then show `systemctl status nginx`.
Run `docker ps` on 203.0.113.10 as user ubuntu on port 2222 using ~/keys/prod.pem.How those map to a tool call (the client fills this in for you):
// "run hostname on 10.0.0.5 with the prod key"
{
"tool": "ssh_exec",
"host": "10.0.0.5",
"command": "hostname",
"key": "prod" // a configured shortcut, or a full path like ~/keys/prod.pem
}
// "tail syslog with sudo on 10.0.0.5"
{
"tool": "ssh_sudo_exec",
"host": "10.0.0.5",
"command": "tail -n 50 /var/log/syslog" // no 'sudo' prefix — the tool adds it
}Tips:
Mention the host, the command, and which key/user/port when they aren't the configured defaults.
Naming the server ("using ssh-mcp…") helps the client pick the right tool when you have several MCP servers registered.
For privileged commands ask for "with sudo" so the client uses
ssh_sudo_exec— and don't putsudoin the command yourself.
Security notes
This server executes arbitrary shell commands on remote hosts, including with
sudoviassh_sudo_exec. Only connect it to hosts and keys you control, and only run it with an MCP client you trust.Private keys are read from disk at call time. Never commit private keys —
*.pem,*.key, and common key filenames are already in.gitignore.Prefer keys that are passphrase-protected or scoped to specific hosts.
The server communicates over stdio with the local MCP client; it does not open any network listener of its own.
License
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Calevi-Consulting/ssh-mcp-dynamic'
If you have feedback or need assistance with the MCP directory API, please join our Discord server