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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.