my-mcp-ssh
An MCP server that enables large language models to connect to remote servers via SSH, execute commands, and transfer files securely.
README
my-mcp-ssh
A Model Context Protocol (MCP) based SSH connection tool that allows large language models to securely connect to remote servers via SSH and perform file operations through the MCP protocol.
Features
- SSH Connection Management: Connect to remote SSH servers
- Command Execution: Execute commands on remote servers
- File Transfer: Upload and download files
- Session Management: Maintain and close SSH sessions
Installation
Dependencies
- Python >= 3.12
- uv package manager
# Clone the project
git clone https://github.com/ffpy/my-mcp-ssh.git
# Enter the project directory
cd my-mcp-ssh
# Install dependencies
uv sync
Usage
Configure in client
{
"mcpServers": {
"my-mcp-ssh": {
"command": "uv",
"args": [
"--directory",
"<your_path>/my-mcp-ssh",
"run",
"src/main.py"
],
"env": {}
}
}
}
Environment Variables
SSH Connection Defaults (Optional)
Environment variables provide default values for SSH connections, useful when frequently connecting to the same server or in automated environments:
SSH_HOST: SSH server hostname or IP addressSSH_PORT: SSH server portSSH_USERNAME: SSH usernameSSH_PASSWORD: SSH password (if using password authentication)SSH_KEY_PATH: SSH private key file path (if using key authentication)SSH_KEY_PASSPHRASE: SSH private key passphrase (if needed)
When to use SSH environment variables:
- Repeated connections: When connecting to the same server multiple times
- CI/CD pipelines: For automated deployment scripts
- Development environments: Set defaults for your commonly used servers
- Container deployments: Configure defaults without modifying code
Note: Parameters passed to the connect tool always override environment variables.
Server Configuration
Additional server behavior can be configured:
SESSION_TIMEOUT: Session timeout in minutes, default is 30 minutesMAX_OUTPUT_LENGTH: Maximum command output length in characters, default is 5000 characters
SSH Credentials File
For better security, you can store SSH credentials in a local configuration file instead of passing passwords as parameters.
- Copy the example file:
cp ssh-credentials.json.example ssh-credentials.json
- Edit
ssh-credentials.jsonwith your actual credentials:
{
"root@192.168.1.100": "your_password",
"admin@web-[0-9].example.com": "web_password",
"deploy@server-{dev,test,staging}.company.com": "deploy_password",
"admin@*.internal.network": "internal_password"
}
Supported Patterns:
*- matches any characters?- matches single character[0-9]- matches any digit{dev,test,staging}- matches any of the listed options
Authentication Priority Order:
- Parameters passed to connect tool (
password,key_path) - Exact match in credentials file (
username@host) - Pattern match in credentials file (wildcards)
- Environment variable password (
SSH_PASSWORD) - Environment variable key (
SSH_KEY_PATH) - Default SSH key (
~/.ssh/id_rsaif exists)
Security:
- File permissions are automatically set to 600 (owner read/write only)
- The file is added to .gitignore to prevent accidental commits
Note:
- Credential file changes take effect immediately without server restart
- The file is read fresh on each connection attempt
Tool List
connect
Connect to an SSH server
Parameters:
host: SSH server hostname or IP address (optional)port: SSH server port (optional, default 22)username: SSH username (optional)password: SSH password for authentication (optional)key_path: SSH private key file path for authentication (optional)key_passphrase: SSH private key passphrase if needed (optional)
disconnect
Disconnect from an SSH session
Parameters:
session_id: The session ID to disconnect
list_sessions
List all active SSH sessions
Parameters:
- None
execute
Execute a command on the SSH server
Parameters:
session_id: Session IDcommand: Command to executestdin: Input string to provide to the command, default is emptytimeout: Command timeout in seconds, default is 60 seconds
upload
Upload a file to the SSH server
Parameters:
session_id: Session IDlocal_path: Local file pathremote_path: Remote file path
download
Download a file from the SSH server
Parameters:
session_id: Session IDremote_path: Remote file pathlocal_path: Local file path
Debugging
Run ./inspector.sh for online debugging
License
my-mcp-ssh is licensed under the Apache License, Version 2.0
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。