An MCP (Model Context Protocol) server that provides SSH client functionality for remote Linux server management. This server enables AI assistants to execute commands on remote Linux hosts via SSH, solving the limitations of built-in tools when working with remote systems.
Built-in MCP tools are limited to local operations. This server extends AI capabilities to remote Linux systems by providing:
- Remote Command Execution: Execute any command on remote Linux hosts
- System Administration: Manage services, check system health, monitor processes
- Secure Authentication: Multiple secure credential storage options
- Enterprise Integration: Works with domain-joined systems and enterprise environments
- SSH Command Execution: Execute arbitrary commands on remote Linux hosts
- Sudo Support: Run commands with elevated privileges (secure password handling)
pip install ssh-mcp-server
git clone https://github.com/rorymcmahon/ssh-mcp-server.git
cd ssh-mcp-server
pip install -e .
- System Information: Get system stats, processes, disk usage, and services
- Secure Credentials: Secure credential storage (currently macOS Keychain, expanding to other providers)
- Connection Management: Automatic connection handling with timeouts
- Error Handling: Comprehensive error reporting and recovery
- Puppet Integration: Run Puppet agent in no-op mode for configuration management
pip install ssh-mcp-server
git clone https://github.com/rorymcmahon/ssh-mcp-server.git
cd ssh-mcp-server
pip install -e .
git clone https://github.com/rorymcmahon/ssh-mcp-server.git
cd ssh-mcp-server
pip install -e ".[dev]"
Add to your MCP client configuration (e.g., Claude Desktop, Q CLI):
{
"mcpServers": {
"ssh": {
"command": "ssh-mcp-server",
"args": []
}
}
}
Execute a command on a remote Linux host via SSH.
Parameters:
hostname
: Target hostname (e.g., "server.company.local")command
: Command to execute
Returns:
{
"status": 0,
"stdout": "total 24\ndrwxr-xr-x 3 user user 4096 ...",
"stderr": ""
}
Or on error:
{
"error": "SSH connection or authentication failed"
}
Execute a command with sudo privileges. Automatically handles password input securely.
Returns: Same format as execute_ssh
Get basic system information (OS, kernel, memory, root disk usage).
Get top 10 CPU-consuming processes.
Get disk usage for all mounted filesystems.
Get top 20 running systemd services.
Run Puppet agent in no-op mode (dry run) with verbose output.
# Execute a simple command
result = execute_ssh("server.company.local", "uptime")
if "error" not in result:
print(result["stdout"]) # System uptime information
# Check system health
system_info = ssh_get_system_info("server.company.local")
disk_usage = get_disk_usage("server.company.local")
processes = get_running_processes("server.company.local")
# Restart a service with sudo
result = execute_sudo("server.company.local", "systemctl restart nginx")
result = execute_ssh("server.company.local", "invalid_command")
if "error" in result:
print(f"Error: {result['error']}")
elif result["status"] != 0:
print(f"Command failed with exit code {result['status']}")
print(f"Error output: {result['stderr']}")
- Credential Storage: Uses secure credential storage (Keychain, future: Vault, AWS Secrets Manager)
- Network Security: Ensure SSH connections are over secure networks
- Access Control: Limit SSH user permissions on target hosts
- Audit Logging: Monitor SSH access and command execution
- TouchID Protection: macOS Keychain integration requires TouchID/password for access
- Password Security: Sudo passwords are passed securely via stdin, not visible in process lists
pytest
black src/ tests/
isort src/ tests/
mypy src/
pytest --cov=ssh_mcp_server --cov-report=html
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
pytest
) - Format code (
black
andisort
) - Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- SSH key-based authentication
- AWS Secrets Manager credential provider
- HashiCorp Vault credential provider
- Azure Key Vault credential provider
- Connection pooling and reuse
- File transfer operations (SCP/SFTP)
- Interactive shell sessions
- Connection health monitoring
- Batch command execution
- Custom SSH client configuration
- Windows support (additional credential providers)
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Changelog: CHANGELOG.md