ssh-mcp is a locally running MCP (Model Context Protocol) server used to manage and operate remote SSH hosts. It supports organizing hosts into groups and executing commands on multiple hosts simultaneously.
Main capabilities include:
Host management:
- add_host: Add a new Linux or Windows host to the SSH configuration, with automatic operating system detection. The username and password in the connection string are optional; when not provided, the current user and SSH agent are used for authentication.
- remove_host: Remove a host from the SSH configuration by group and name.
- get_groups: Get a list of all groups.
- get_hosts: Get a list of hosts, filterable by group.
- get_os_info: Get cached operating system information for Linux and Windows hosts, for a single host or an entire group.
- update_os_info: Update the cached system information of hosts, for a single host or an entire group.
Command execution:
- perform_command: Log in to a remote machine via SSH and execute a command, for a single host or an entire group. Commands that run longer than 30 seconds are automatically switched to background execution; you can also set background=true to run in the background immediately.
Command management:
- get_command_status: Get the status and result of a background command by command ID; when no ID is provided, returns the most recent command.
- list_commands: List all background commands and their current status, making it easy to track long-running tasks.
- cancel_command: Cancel a running background command by command ID.
Other features:
- Cross-platform support: Supports both Linux and Windows remote hosts, with automatic operating system detection.
- Group management: Group hosts for unified management.
- Multiple authentication methods: Supports password, SSH agent, and SSH key files (~/.ssh/id_rsa, id_ed25519, etc.).
- Secure host verification: Uses ~/.ssh/known_hosts for host key verification and automatically adds hosts.
- Concurrent execution: Can execute commands on multiple hosts simultaneously.
- Automatic background execution: Commands exceeding 30 seconds are automatically moved to the background, returning a command ID for status tracking.
- Persistent storage: Uses BadgerDB for efficient local storage.
Limitations and notes:
- SSH agent support is limited to Unix systems (SSH_AUTH_SOCK); password and key file authentication are available on all platforms.
- Remote hosts can be Linux or Windows (automatic system detection).
Usage:
- Check out the repository and build the binary.
- Update the MCP configuration of Claude Desktop.
- Restart Claude Desktop.
- Add hosts to groups via add_host (supports multiple formats, the ssh:// prefix is optional).
- Use get_groups and get_hosts to list groups and hosts, filterable by group.
- Use get_os_info and update_os_info to get or update system information.
- Use perform_command to execute commands on a group or specified hosts; long commands are automatically run in the background.
- Use get_command_status, list_commands, and cancel_command to manage background commands.
Applicable scenarios include: batch server operations and maintenance, cross-host command execution, automated tasks, and scenarios that require unified management of multiple Linux/Windows hosts.