This MCP server enables AI agents to establish and manage persistent SSH sessions for executing commands on remote systems.
Core Capabilities:
Execute commands on SSH hosts using persistent, reusable connections across multiple operations
Multi-host management - connect to and manage multiple remote hosts simultaneously
Session management - list active sessions, close individual sessions by host identifier, or terminate all sessions at once
Connection Features:
SSH config support - automatically reads
~/.ssh/config
for host aliases, hostnames, ports, users, and identity filesFlexible authentication - supports passwords, SSH keys, and explicit connection parameters
Automatic reconnection - detects and re-establishes dead connections
Thread-safe operations for concurrent usage
Specialized Support:
Network device handling - automatic enable mode management for routers and switches
Sudo support - automatic password handling for privileged commands on Unix/Linux systems
Enables persistent SSH connections to Linux systems for executing commands, managing services with sudo support, and performing system administration tasks remotely.
MCP SSH Session
An MCP (Model Context Protocol) server that enables AI agents to establish and manage persistent SSH sessions.
Features
Persistent Sessions: SSH connections are reused across multiple command executions
SSH Config Support: Automatically reads and uses settings from
~/.ssh/config
Multi-host Support: Manage connections to multiple hosts simultaneously
Automatic Reconnection: Dead connections are detected and automatically re-established
Thread-safe: Safe for concurrent operations
Network Device Support: Automatic enable mode handling for routers and switches
Sudo Support: Automatic password handling for sudo commands on Unix/Linux hosts
Installation
Using Claude Code
Add to your ~/.claude.json
:
Replace /path/to/mcp-ssh-session
with the actual path to this project.
Using MCP Inspector
Development Installation
Usage
Available Tools
execute_command
Execute a command on an SSH host using a persistent session.
Using SSH config alias:
Using explicit parameters:
Network device with enable mode:
Unix/Linux with sudo:
list_sessions
List all active SSH sessions.
close_session
Close a specific SSH session.
close_all_sessions
Close all active SSH sessions.
SSH Config Support
The server automatically reads ~/.ssh/config
and supports:
Host aliases
Hostname mappings
Port configurations
User specifications
IdentityFile settings
Example ~/.ssh/config
:
Then simply use:
Documentation
See CLAUDE.md for detailed documentation.
License
[Add license information]
local-only server
The server can only run on the client's local machine because it depends on local resources.
Enables AI agents to establish and manage persistent SSH connections to remote hosts for executing commands. Supports SSH config files, multi-host management, and automatic reconnection with thread-safe concurrent operations.