Expand description
SSH MCP Server - A Model Context Protocol server for remote SSH command execution
This crate provides an MCP server that allows executing commands on remote Linux
systems via SSH. It supports both password and key-based authentication, as well
as privilege elevation via su and sudo.
§Features
- Execute shell commands on remote SSH servers (
exectool) - Support for
sudocommand execution with password (sudo-exectool) - Persistent SSH connection with auto-reconnect
- Configurable command timeout
- Command length limits for safety
§MCP Tools
exec- Execute a shell command on the remote SSH serversudo-exec- Execute a command with sudo privileges (can be disabled with--disable-sudo)read-file- Read a remote UTF-8 file with preview/head/tail/full modeswrite-file- Atomically overwrite or create a remote UTF-8 filereplace-in-file- Atomically replace text within a remote UTF-8 file
§Example Usage (CLI)
ssh-mcp --host=192.168.1.100 --user=admin --password=secret§Example Usage (MCP Inspector)
npx @modelcontextprotocol/inspector ./target/release/ssh-mcp -- \
--host=YOUR_HOST --user=root --password=passRe-exports§
pub use config::Args;pub use config::Config;pub use error::Result;pub use error::SshMcpError;pub use server::SshMcpServer;pub use ssh::CommandOutput;pub use ssh::HostKeyCheckMode;pub use ssh::SshConfig;pub use ssh::SshConnectionManager;pub use ssh::SshHandler;pub use ssh::escape_command_for_shell;pub use ssh::escape_for_shell;pub use ssh::escape_for_timeout_wrapper;pub use ssh::sanitize_command;pub use ssh::sanitize_password;pub use ssh::wrap_command_with_timeout;pub use ssh::wrap_sudo_command;pub use tools::CheckProcessParams;pub use tools::ExecParams;pub use tools::SudoExecParams;
Modules§
- background
- Local background job state + log spooling (Phase 1 scaffold).
- config
- Configuration and CLI argument parsing for SSH MCP Server
- error
- Error types for SSH MCP Server
- logging
- Logging initialization and configuration
- server
- MCP Server implementation
- ssh
- SSH connection management module
- ticket
- Cryptographic read-ticket module.
- tools
- MCP Tools module
- transfer
- File and directory transfer tool support.