mcp-remote-ssh
v0.5.1MCP server for remote SSH operations -- persistent sessions, structured command execution, SFTP file transfer, and port forwarding for AI agents.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
ssh_connect
Connect to a remote host via SSH. Returns a session_id for use with all other tools. Supports password and key-based authentication.
| Parameter | Type | Description |
|---|---|---|
host * | string | Hostname or IP address of the remote server. |
key_path | string | Path to SSH private key file. Leave empty for password auth. |
password | string | Password for authentication. Leave empty for key-based auth. |
port | integer | SSH port (default: 22). |
record | boolean | Start transcript recording immediately on connect (default: False). |
timeout | integer | Connection timeout in seconds (default: 60). |
username | string | SSH username (default: root). |
ssh_list_sessions
List all active SSH sessions with their connection status and details. Returns: List of session info dicts.
ssh_close_session
Close an SSH session and release all its resources (shell, SFTP, port forwards). WARNING: this kills any running processes in the session.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
ssh_execute
Execute a command on the remote host and return structured output. Each call runs in an independent exec channel -- no state is shared between calls (use ssh_shell_* tools for persistent state). If secrets have been loaded via ssh_load_env_file, they are automatically injected as environment variables for this command.
| Parameter | Type | Description |
|---|---|---|
command * | string | Shell command to execute. |
session_id * | string | The session ID returned by ssh_connect. |
timeout | integer | Maximum seconds to wait for the command to finish (default: 120). |
ssh_sudo_execute
Execute a command with sudo on the remote host. If the user already has passwordless sudo, leave sudo_password empty. If secrets have been loaded via ssh_load_env_file, they are automatically injected as environment variables for this command.
| Parameter | Type | Description |
|---|---|---|
command * | string | Shell command to execute under sudo. |
session_id * | string | The session ID returned by ssh_connect. |
sudo_password | string | Password for sudo prompt (empty for passwordless sudo). |
timeout | integer | Maximum seconds to wait (default: 120). |
ssh_forward_port
Create an SSH port forward (local -> remote). Connections to 127.0.0.1:local_port will be tunneled through SSH to remote_host:remote_port. If local_port is 0, a random available port is chosen.
| Parameter | Type | Description |
|---|---|---|
remote_port * | integer | Port on the remote side to forward to. |
session_id * | string | The session ID returned by ssh_connect. |
local_port | integer | Local port to listen on (0 = auto-assign). |
remote_host | string | Host on the remote side (default: localhost, i.e. the SSH server itself). |
ssh_list_forwards
List all active port forwards for an SSH session.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
ssh_close_forward
Close a specific port forward.
| Parameter | Type | Description |
|---|---|---|
forward_id * | string | The forward ID returned by ssh_forward_port. |
session_id * | string | The session ID returned by ssh_connect. |
ssh_load_env_file
Load environment variables from a LOCAL file (on the machine running this MCP server) into the remote SSH session. The file is read from the local filesystem -- it does NOT need to exist on the remote host. Variable VALUES are never returned to the caller; only variable names are confirmed. Loaded values are: 1. Registered for automatic redaction -- any subsequent tool output (ssh_execute, ssh_shell_send, ssh_shell_read, ssh_read_remote_file) that contains a secret value will have it replaced with '***'. 2. Exported into the remote shell (if open) via builtins, avoiding exposure in…
| Parameter | Type | Description |
|---|---|---|
file_path * | string | Absolute path to the env file on the LOCAL machine (where this MCP server is running). |
session_id * | string | The session ID returned by ssh_connect. |
ssh_clear_secrets
Clear all loaded secrets from the redaction registry. Secrets will no longer be redacted from tool output. Does NOT unset the environment variables from the remote shell.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
ssh_upload_file
Upload a local file to the remote host via SFTP.
| Parameter | Type | Description |
|---|---|---|
local_path * | string | Path to the file on the local machine. |
remote_path * | string | Destination path on the remote host. |
session_id * | string | The session ID returned by ssh_connect. |
ssh_download_file
Download a file from the remote host to the local machine via SFTP.
| Parameter | Type | Description |
|---|---|---|
local_path * | string | Destination path on the local machine. |
remote_path * | string | Path to the file on the remote host. |
session_id * | string | The session ID returned by ssh_connect. |
ssh_read_remote_file
Read a text file on the remote host and return its contents. For large files, use max_bytes to limit the amount read.
| Parameter | Type | Description |
|---|---|---|
remote_path * | string | Path to the file on the remote host. |
session_id * | string | The session ID returned by ssh_connect. |
max_bytes | integer | Maximum bytes to read (default: 1MB). Set to 0 for no limit. |
ssh_write_remote_file
Write text content to a file on the remote host via SFTP.
| Parameter | Type | Description |
|---|---|---|
content * | string | Text content to write. |
remote_path * | string | Path to the file on the remote host. |
session_id * | string | The session ID returned by ssh_connect. |
append | boolean | If True, append to existing file instead of overwriting (default: False). |
ssh_list_remote_dir
List files and directories at a path on the remote host via SFTP.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
remote_path | string | Directory path on the remote host (default: current directory). |
ssh_shell_open
Open a persistent interactive shell on the SSH session. The shell preserves working directory, environment variables, and running processes across multiple send/read calls. Ideal for screen/tmux, long builds, etc. If a shell is already open, this is a no-op (returns existing shell info). If secrets have been loaded via ssh_load_env_file, they are automatically injected into the new shell.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
height | integer | Terminal height in rows (default: 50). |
term | string | Terminal type (default: xterm). |
width | integer | Terminal width in columns (default: 200). |
ssh_shell_send
Send text to the interactive shell. By default appends Enter (newline) and waits briefly to capture output.
| Parameter | Type | Description |
|---|---|---|
data * | string | Text to send to the shell. |
session_id * | string | The session ID returned by ssh_connect. |
press_enter | boolean | Whether to append a newline after the text (default: True). |
read_lines | integer | Number of tail lines to return from the shell buffer (default: 100). |
wait | number | Seconds to wait for output after sending (default: 1.0). |
ssh_shell_read
Read the current content of the interactive shell buffer. Use this to poll for output from long-running commands without sending anything.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
lines | integer | Number of tail lines to return (default: 100). |
ssh_shell_send_control
Send a control character to the interactive shell. Common keys: "c" for Ctrl+C (interrupt), "d" for Ctrl+D (EOF), "z" for Ctrl+Z (suspend), "l" for Ctrl+L (clear screen), "a" for Ctrl+A (screen prefix).
| Parameter | Type | Description |
|---|---|---|
key * | string | Single letter for the control key (e.g. "c" sends Ctrl+C). |
session_id * | string | The session ID returned by ssh_connect. |
ssh_shell_wait
Wait for the shell output to contain a specific pattern, or for the output to stabilize (no new output for two poll intervals). Useful for waiting on long-running commands to complete.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
lines | integer | Number of tail lines to return (default: 100). |
pattern | string | Text pattern to wait for (e.g. a shell prompt like "$ " or "# "). If empty, waits for output to stabilize. |
poll_interval | number | Seconds between polls (default: 2.0). |
timeout | integer | Maximum seconds to wait (default: 300). |
ssh_start_recording
Start recording all SSH interactions (commands, output, shell I/O) for this session. If already recording, this is a no-op.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
ssh_stop_recording
Stop recording SSH interactions for this session. The transcript is preserved and can still be retrieved with ssh_get_transcript.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
ssh_get_transcript
Retrieve the session transcript. Can return all entries or just the last N. Supports text (human-readable) or jsonl format.
| Parameter | Type | Description |
|---|---|---|
session_id * | string | The session ID returned by ssh_connect. |
fmt | string | Output format -- "text" for human-readable log, "jsonl" for structured JSON lines (default: text). |
last_n | integer | Return only the last N entries. 0 means all (default: 0). |
ssh_save_transcript
Save the session transcript to a local file on the machine running the MCP server (not the remote host).
| Parameter | Type | Description |
|---|---|---|
path * | string | Local file path to save the transcript to. |
session_id * | string | The session ID returned by ssh_connect. |
fmt | string | Format -- "text" for human-readable, "jsonl" for structured (default: text). |