mcp-remote-ssh
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., "@mcp-remote-sshssh to staging host and execute 'uptime'"
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.
mcp-remote-ssh
MCP server giving AI agents full SSH access -- persistent sessions, structured command output, SFTP file transfer, port forwarding, and secret-safe environment variable injection with automatic output redaction.
Why this exists
Every other SSH MCP server is missing something: no password auth, no persistent sessions, no SFTP, no port forwarding, or no structured exit codes. This one has all of them -- plus the only MCP-level secret management that prevents AI agents from ever seeing your credentials.
Related MCP server: ssh-mcp
Secret-Safe Environment Variables
The problem: When an AI agent needs to use API tokens, passwords, or keys on a remote server, the standard approach exposes secrets in the LLM's context window. The agent either reads the secret file (now it's in the conversation) or runs echo $TOKEN and sees the value in the output.
The solution: ssh_load_env_file reads secrets from a local file on your machine, injects them into the remote SSH session, and registers them for automatic output redaction. The AI agent can use the variables freely -- every tool response is scrubbed before it reaches the LLM.
# Agent calls this -- file is read from YOUR machine, not the remote host
ssh_load_env_file(session_id="abc", file_path="~/.secrets/prod.env")
→ "Loaded 3 variables from local:~/.secrets/prod.env: API_TOKEN, DB_PASS, SECRET_KEY"
# Agent tries to echo the value -- redacted automatically
ssh_execute(session_id="abc", command="echo $API_TOKEN")
→ {"stdout": "***\n", "exit_code": 0}
# Agent dumps the environment -- all secret values scrubbed
ssh_execute(session_id="abc", command="env | grep API_TOKEN")
→ {"stdout": "API_TOKEN=***\n", "exit_code": 0}
# Agent reads a file containing a secret -- also redacted
ssh_read_remote_file(session_id="abc", remote_path="/etc/app/config")
→ "db_password=***\ndb_host=localhost\n"
# Normal commands work perfectly -- no over-redaction
ssh_execute(session_id="abc", command="uname -a")
→ {"stdout": "Linux server 6.1.0 ...", "exit_code": 0}How it works
┌─────────┐ ┌──────────────────────────────┐ ┌─────────────┐
│ LLM │ ←─JSON─ │ MCP Server (your machine) │ ──SSH─→ │ Remote Host │
│ (Agent) │ │ │ │ │
└─────────┘ │ 1. Reads ~/.secrets/prod.env│ └─────────────┘
│ 2. Parses KEY=VALUE pairs │
│ 3. Stores values in memory │
│ 4. Injects into SSH session │
│ 5. Redacts ALL tool output │
└──────────────────────────────┘Local file read -- the env file lives on your machine, never on the remote host
Shell injection via builtins -- uses
read -r VAR <<< 'value' && export VAR(no process tree exposure)Stdin-based exec injection --
ssh_executefeeds secrets via stdin to a bash wrapper, so they never appear in/proc/*/cmdlineAutomatic redaction -- every tool response (
ssh_execute,ssh_shell_send,ssh_shell_read,ssh_read_remote_file) is scrubbed before reaching the LLMLongest-first matching -- prevents partial-match corruption (e.g.,
abc123is replaced beforeabc)
Security properties
Threat | Mitigated? | How |
Secret in LLM context window | Yes | Output redaction replaces values with |
Secret in remote process tree (shell) | Yes | Shell builtins ( |
Secret in remote process tree (exec) | Yes | Secrets fed via stdin, never in |
LLM tries | N/A | File is local-only, doesn't exist on remote |
LLM tries | Yes | Output is redacted |
Encoded/transformed secret (base64) | No | Only literal matches are redacted |
MITM on first SSH connection | Accepted |
|
Host key policy
This server uses Paramiko's AutoAddPolicy — unknown host keys are accepted without prompting. This is intentional for QE/lab environments where hosts are ephemeral (Beaker, cloud instances, CI machines). The trade-off:
Pro: Zero-friction connections to newly provisioned machines
Con: Vulnerable to MITM on the very first connection to an unknown host
If you operate on untrusted networks, consider wrapping connections through a VPN or SSH bastion with pre-distributed host keys. A host_key_policy parameter may be added in a future release for strict environments.
Env file format
Standard .env format:
# Comments are ignored
API_TOKEN=your-secret-token
DB_PASSWORD="quoted values work"
SECRET_KEY='single quotes too'
export ALSO_WORKS=yesInstallation
uvx mcp-remote-ssh # or: pip install mcp-remote-sshConfiguration
{
"mcpServers": {
"remote-ssh": {
"command": "uvx",
"args": ["mcp-remote-ssh"]
}
}
}Tools (20)
Connection
Tool | Description |
| Connect with password, key, or agent auth. Returns |
| List active sessions |
| Close a session and release resources |
Execution
Tool | Description |
| Run a command, returns |
| Run with sudo elevation |
Interactive Shell
Tool | Description |
| Open persistent shell (preserves cwd, env, processes) |
| Send text (with optional Enter) |
| Read current output buffer |
| Send Ctrl+C, Ctrl+D, etc. |
| Wait for a pattern or output to stabilize |
Secrets Management
Tool | Description |
| Load secrets from a local env file; values never returned to the LLM |
| Clear redaction registry (values become visible again) |
SFTP
Tool | Description |
| Upload local file to remote host |
| Download remote file to local machine |
| Read a remote text file |
| Write/append to a remote file |
| List directory with metadata |
Port Forwarding
Tool | Description |
| Create SSH tunnel (local -> remote) |
| List active tunnels |
| Close a tunnel |
Quick start
ssh_connect(host="server.example.com", username="admin", password="secret")
→ {"session_id": "a1b2c3d4", "connected": true}
ssh_load_env_file(session_id="a1b2c3d4", file_path="~/.secrets/prod.env")
→ "Loaded 2 variables: API_TOKEN, DB_PASS"
ssh_execute(session_id="a1b2c3d4", command="curl -H \"Authorization: Bearer $API_TOKEN\" https://api.example.com")
→ {"stdout": "{\"status\": \"ok\"}", "exit_code": 0} # token used but never visible
ssh_shell_open(session_id="a1b2c3d4")
ssh_shell_send(session_id="a1b2c3d4", data="cd /opt && make -j$(nproc)")
ssh_shell_wait(session_id="a1b2c3d4", pattern="$ ", timeout=600)
ssh_upload_file(session_id="a1b2c3d4", local_path="config.yaml", remote_path="/etc/app/config.yaml")
ssh_forward_port(session_id="a1b2c3d4", remote_port=5432, local_port=15432)Design
Built on Paramiko (SSH) + FastMCP (MCP protocol).
ssh_executeusesexec_command()for clean structured output with real exit codesWhen secrets are loaded,
ssh_executefeeds exports via stdin to abashwrapper, thenexecs the actual command -- secrets never appear in the process treessh_shell_*usesinvoke_shell()for persistent interactive sessionsAll blocking Paramiko calls run in
run_in_executorto stay asyncShell keeps a 500KB rolling buffer for
shell_readpollingSecret redaction uses longest-first string replacement across all output paths
License
MIT
Maintenance
Latest Blog Posts
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/faizbawa/mcp-remote-ssh'
If you have feedback or need assistance with the MCP directory API, please join our Discord server