ssh-mcp
Enables persistent SSH connections to Linux hosts and network devices, with secure credential storage, configuration backup/restore, SFTP, and SSH tunneling.
README
ssh-mcp v4.0
MCP server for persistent SSH work across Linux hosts and network devices.
Features
- Persistent SSH connections with automatic reconnection
- Secure credential storage via Windows Credential Manager
- Network device support: Cisco IOS/IOS-XE/XR, MikroTik, FortiGate, Juniper
- Config management: backup, restore, diff for network devices
- SFTP: upload, download, list remote files
- SSH tunnels: persistent port forwarding
- Rate limiting: prevents device saturation (100ms minimum between commands)
- Smart connection: use
ssh_connect(alias='vps')to load saved credentials automatically
Quick Start
1. Save a server (once)
ssh_save_server(
alias='vps',
host='192.168.10.1',
username='sassogba',
password='your-password',
auto_connect=True # Auto-connect on startup
)
2. Connect (simple mode)
ssh_connect(alias='vps') # Loads credentials from servers.json
3. Execute commands
ssh_exec(alias='vps', command='df -h')
ssh_exec_sudo(alias='vps', command='systemctl restart nginx', sudo_password='...')
What's New in v4.0
Smart Connection Mode
ssh_connectnow accepts just an alias to load credentials automatically- No need to provide host, username, password every time
- Fixes Claude Code integration issues
Critical Fixes
- Timeout handling: Now raises
TimeoutErrorinstead of silently returning incomplete buffers - Rate limiting: 100ms minimum between network commands to prevent device saturation
- Magic numbers eliminated: Named constants for shell dimensions
Documentation
- New
CLAUDE_CODE_USAGE.mdwith complete usage examples - New
CLAUDE_CODE_SETUP.mdfor configuration - New
CHANGELOG.mdwith full version history
Security Model
servers.json only keeps non-sensitive metadata. Secrets live in Windows Credential Manager under targets like:
ssh-mcp:<alias>:passwordssh-mcp:<alias>:key_passphrase
Host Key Policy
strict: default, rejects unknown host keys (production)auto_add: accepts unknown host keys (lab only)
Network Devices
Supported device types:
cisco- Cisco IOS/IOS-XEcisco_xr- Cisco IOS-XRmikrotik- MikroTik RouterOSfortigate- FortiGate FortiOSjuniper- Juniper JunOSgeneric- Linux/Unix (default)
Example: Cisco backup
# Save once
ssh_save_server(
alias='cisco-core',
host='10.0.0.1',
username='admin',
password='...',
device_type='cisco',
auto_connect=True
)
# Connect
ssh_connect(alias='cisco-core')
# Backup config
ssh_backup_config(alias='cisco-core', device_type='cisco')
# Saved to: backups/cisco-core/cisco-core_2026-05-31_14-30-00.txt
# Execute commands
ssh_exec_network(
alias='cisco-core',
commands=['show version', 'show ip interface brief'],
device_type='cisco'
)
# Push config
ssh_push_config(
alias='cisco-core',
config='''
interface GigabitEthernet0/1
description Uplink to Core
ip address 10.0.1.1 255.255.255.0
no shutdown
''',
device_type='cisco',
save_config=True
)
Usage with Claude Code
See CLAUDE_CODE_USAGE.md for detailed examples.
TL;DR:
1. Save: ssh_save_server(alias='vps', host='192.168.10.1', username='sassogba', password='...')
2. Connect: ssh_connect(alias='vps')
3. Execute: ssh_exec(alias='vps', command='df -h')
18 Tools Available
Connection Management
ssh_connect- Establish persistent SSH connection (smart mode: just provide alias)ssh_disconnect- Close connection and tunnelsssh_list- List active connections with status
Persistent Configuration
ssh_save_server- Save server to servers.json (secrets in Credential Manager)ssh_remove_server- Remove saved serverssh_list_servers- List all saved servers
Linux/Unix Execution
ssh_exec- Execute shell commandssh_exec_sudo- Execute with sudo (auto password injection)
Network Device Execution
ssh_exec_network- Execute commands on network devices (handles pagination, prompts)ssh_push_config- Deploy configuration blockssh_backup_config- Backup running config to local filessh_restore_config- Restore config from backup filessh_diff_config- Compare configs (git-style diff)
SFTP
ssh_upload- Upload file to remote serverssh_download- Download file from remote serverssh_list_remote- List remote directory contents
Tunnels
ssh_tunnel- Create persistent SSH tunnel (port forwarding)ssh_close_tunnel- Close tunnel by label
Architecture
- SSHPool: Thread-safe connection pool with automatic reconnection
- SSHConnection: Per-connection state with RLock for thread safety
- ThreadPoolExecutor: Async/await wrapper for Paramiko (which is synchronous)
- Rate limiter: 100ms minimum between commands to prevent device saturation
- Timeout handling: Multiple levels (per-command, total, absolute) with proper error propagation
Requirements
paramiko>=3.0.0
mcp>=1.0.0
pywin32>=306
Install with:
pip install -r requirements.txt
Run Tests
python -m pytest tests -v
Documentation
- CLAUDE_CODE_USAGE.md - Usage examples for Claude Code
- CLAUDE_CODE_SETUP.md - Configuration guide
- CHANGELOG.md - Version history and migration guide
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。