SSH MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SSH MCP Server execute 'df -h' on the remote host"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SSH MCP Server
A Model Context Protocol server for comprehensive SSH operations
Developed by XNet Inc. | Project Lead: Joshua S. Doucette
Overview
SSH MCP Server exposes comprehensive SSH functionality to AI assistants through the Model Context Protocol (MCP). It provides a stateless, production-ready solution for remote system management, file transfers, and secure tunneling.
Version: 0.2.0 (Stateless Design)
License: MIT
Repository: https://github.com/XNet-NGO/ssh-mcp-server
Related MCP server: Simple SSH MCP Server
Key Features
Core Capabilities
✅ Connection Management - Stateless SSH connections with base64-encoded session IDs
✅ Command Execution - Execute remote commands with full output capture
✅ File Operations - SFTP upload/download with directory listing
✅ Key Management - Generate, list, and fingerprint SSH keys
✅ Port Forwarding - Local, remote, and dynamic SSH tunnels
✅ Configuration - Manage SSH client settings and known_hosts
Technical Highlights
🚀 Stateless Architecture - Works with ephemeral Docker containers
🔒 Security First - Built on OpenSSH with comprehensive error handling
📦 Docker Ready - Optimized for Docker MCP Gateway
📚 AI Documentation - Built-in training docs for AI assistants
⚡ Fast Execution - Sub-500ms command execution
🧪 Well Tested - Unit tests, integration tests, and property-based tests
Quick Start
Installation
npm install @xnet-ngo/ssh-mcp-serverDocker
# From GitHub Container Registry (recommended)
docker pull ghcr.io/xnet-ngo/ssh-mcp-server:0.2.0
# Or use latest
docker pull ghcr.io/xnet-ngo/ssh-mcp-server:latestUsage with MCP
Add to your MCP configuration:
{
"mcpServers": {
"ssh": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "~/.ssh:/root/.ssh:ro",
"ghcr.io/xnet-ngo/ssh-mcp-server:0.2.0"
]
}
}
}Architecture
Stateless Design
The SSH MCP Server uses a stateless wrapper-first approach, designed for ephemeral container environments:
// Session IDs are self-contained
sessionId = base64(JSON.stringify({
host: "example.com",
port: 22,
username: "user",
privateKey: "...", // or keyPath
config: { strictHostKeyChecking: false }
}))Benefits:
✅ No state persistence required
✅ Works with
docker run --rm✅ Sessions recreate automatically
✅ Compatible with Docker MCP Gateway
Components
ssh-mcp-server/
├── src/
│ ├── core/ # Core functionality
│ │ ├── ConnectionManager.ts # Session management
│ │ ├── SSHWrapper.ts # SSH command wrapper
│ │ └── types.ts # Type definitions
│ ├── tools/ # MCP tool implementations
│ │ ├── ConnectionTools.ts # Connect/disconnect
│ │ ├── CommandExecutionTools.ts # Execute commands
│ │ ├── FileTransferTools.ts # SFTP operations
│ │ ├── KeyManagementTools.ts # Key operations
│ │ ├── PortForwardingTools.ts # SSH tunnels
│ │ └── ConfigurationTools.ts # SSH config
│ ├── mcp/ # MCP server setup
│ └── server.ts # Main entry point
├── tests/ # Test suite
├── docs/ # Documentation
│ ├── AI_USAGE_GUIDE.md # AI assistant guide
│ └── QUICK_REFERENCE.md # Quick reference
└── Dockerfile.ssh # Docker imageAvailable Tools
Connection Management (3 tools)
ssh_connect- Establish SSH connectionssh_disconnect- Close connectionssh_list_sessions- List active sessions
Command Execution (1 tool)
ssh_execute- Execute remote commands
File Transfer (4 tools)
sftp_upload- Upload filessftp_download- Download filessftp_list- List directory contentssftp_delete- Delete remote files
Key Management (3 tools)
ssh_keygen- Generate SSH key pairsssh_list_keys- List available keysssh_fingerprint- Get key fingerprint
Port Forwarding (2 tools)
ssh_port_forward- Create SSH tunnelssh_close_forward- Close tunnel
Configuration (2 tools)
ssh_get_config- Get SSH configurationssh_set_option- Set SSH option
Usage Examples
Connect and Execute Command
// Connect
const conn = await ssh_connect({
host: "example.com",
username: "user",
privateKeyBase64: keyBase64,
config: { strictHostKeyChecking: false }
});
// Execute command
const result = await ssh_execute({
sessionId: conn.sessionId,
command: "uptime"
});
console.log(result.stdout);
// Output: 08:08:15 up 1 day, 1:43, 2 users, load average: 0.00, 0.00, 0.00File Transfer
// Upload file
await sftp_upload({
sessionId: conn.sessionId,
localPath: "/local/config.json",
remotePath: "/etc/app/config.json"
});
// Download file
await sftp_download({
sessionId: conn.sessionId,
remotePath: "/var/log/app.log",
localPath: "/tmp/app.log"
});Port Forwarding
// Create local forward
await ssh_port_forward({
sessionId: conn.sessionId,
type: "local",
localPort: 8080,
remoteHost: "localhost",
remotePort: 80
});
// Now access http://localhost:8080 to reach remote port 80Documentation
Usage Guide - Comprehensive usage documentation
AI Usage Guide - Guide for AI assistants
Quick Reference - Quick reference guide
Changelog - Version history
Contributing - Contribution guidelines
Docker MCP Gateway
This server is optimized for use with Docker MCP Gateway:
{
"mcpServers": {
"MCP_DOCKER": {
"command": "docker",
"args": [
"mcp", "gateway", "run",
"--servers=ssh-mcp-server"
],
"autoApprove": ["*"]
}
}
}Note: When using Docker MCP Gateway, use base64-encoded private keys to bypass secret detection:
const keyBase64 = Buffer.from(privateKeyContent).toString('base64');Development
Prerequisites
Node.js >= 18.0.0
Docker (for containerized deployment)
OpenSSH client tools
Setup
# Clone repository
git clone https://github.com/XNet-NGO/ssh-mcp-server.git
cd ssh-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Run in development
npm run devTesting
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run in watch mode
npm run test:watch
# Lint code
npm run lint
# Format code
npm run formatBuilding Docker Image
# Build image
docker build -f Dockerfile.ssh -t ghcr.io/xnet-ngo/ssh-mcp-server:0.2.0 .
# Run container
docker run --rm -i \
-v ~/.ssh:/root/.ssh:ro \
ghcr.io/xnet-ngo/ssh-mcp-server:0.2.0Security Considerations
Best Practices
✅ Use Ed25519 keys (faster and more secure than RSA)
✅ Rotate keys regularly
✅ Use different keys for different environments
✅ Set appropriate timeouts
✅ Monitor SSH connections and logs
Base64 Encoding
When using Docker MCP Gateway, private keys must be base64-encoded to bypass secret detection. Note: Base64 is NOT encryption - use only in trusted environments.
Performance
Connection: ~1s
Command Execution: 400-500ms
File Operations: Depends on file size and network
Session Recreation: < 100ms
Troubleshooting
Common Issues
Permission denied (publickey)
Verify private key is correct
Ensure public key is in remote
~/.ssh/authorized_keysCheck key file permissions (should be 0600)
Host key verification failed
Set
strictHostKeyChecking: falsein configOr add host to known_hosts
Connection timeout
Verify host is reachable
Check firewall rules
Increase
connectTimeoutin config
See Usage Guide for more troubleshooting tips.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Ways to Contribute
🐛 Report bugs
💡 Suggest features
📝 Improve documentation
🧪 Add tests
💻 Submit pull requests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright
Copyright (c) 2026 XNet Inc.
Copyright (c) 2026 Joshua S. Doucette
Acknowledgments
This project builds upon:
OpenSSH Portable (BSD License)
Model Context Protocol SDK (MIT License)
Original SSH MCP Server Contributors (2025)
See CONTRIBUTORS.md for full attribution.
Support
Email: contact@xnet.ngo
Website: https://xnet.ngo
About XNet
XNet Inc. is a non-governmental organization focused on developing open-source tools and infrastructure for secure communications and remote system management.
Website: https://xnet.ngo
GitHub: https://github.com/XNet-NGO
Project: SSH MCP Server
Version: 0.2.0
Copyright: © 2026 XNet Inc., Joshua S. Doucette
License: MIT
Repository: https://github.com/XNet-NGO/ssh-mcp-server
Available Tools
15 toolssftp_deleteB
Delete a file on remote system
Inputs: sessionId (required), remotePath (required).
sftp_downloadB
Download a file from remote system via SFTP
Inputs: localPath (required), sessionId (required), remotePath (required).
sftp_listB
List contents of a remote directory
Inputs: sessionId (required), remotePath (required).
sftp_uploadB
Upload a file to remote system via SFTP
Inputs: localPath (required), sessionId (required), remotePath (required).
ssh_close_forwardB
Close an SSH tunnel
Inputs: forwardId (required).
ssh_connectC
Establish an SSH connection to a remote host
Inputs: host (required), username (required), port, keyPath, +1 more.
ssh_disconnectB
Close an SSH connection
Inputs: sessionId (required).
ssh_executeC
Execute a command on a remote system via SSH
Inputs: command (required), sessionId (required), timeout.
ssh_fingerprintC
Get fingerprint of an SSH key
Inputs: keyPath (required).
ssh_get_configC
Get SSH configuration for a host
Inputs: hostname (required).
ssh_keygenB
Generate a new SSH key pair
Inputs: bits (required), path (required), algorithm (required), passphrase.
ssh_list_keysC
List available SSH keys
Inputs: directory.
ssh_list_sessionsA
List all active SSH sessions
Inputs: no named parameters.
ssh_port_forwardC
Create an SSH tunnel for port forwarding
Inputs: type (required), sessionId (required), localPort, remoteHost, +1 more.
ssh_set_optionC
Set an SSH configuration option
Inputs: key (required), value (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Each tool targets a distinct resource/action: connection lifetime, session management, command execution, SFTP file operations, key management, port forwarding, and configuration. No two tools overlap in purpose, making selection unambiguous.
All tools follow a consistent verb_noun pattern, with 'ssh_' prefix for most operations and 'sftp_' for file transfers. The naming convention is predictable and clearly indicates the action and target.
15 tools cover a comprehensive SSH toolkit without bloat. Each tool earns its place, spanning connection, execution, file transfer, key management, tunneling, and configuration.
Core SSH workflows are well covered: connect/disconnect, execute, SFTP operations, key generation/listing/fingerprint, port forward setup/teardown, and config read/write. Minor gaps like listing active port forwards or deleting keys exist but do not break common workflows.
Maintenance
Related MCP Connectors
Secure and manage MCP servers through the Speakeasy AI Control Plane from your agent.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Connect any AI agent to 1,000+ apps and 27,000+ actions through one remote MCP server (OAuth).
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables remote SSH command execution and bidirectional file transfers through a standardized interface. It allows AI assistants to securely manage remote servers while keeping credentials isolated and applying command-level security controls.ISC
- AlicenseNot gradedqualityDmaintenanceAn MCP server that gives AI assistants full SSH/SFTP remote operations — session management, command execution, interactive shells, file transfers, port forwarding, and system diagnostics.2MIT
- AlicenseNot gradedqualityCmaintenanceMCP server enabling AI assistants to securely operate remote servers via persistent SSH sessions, with tools for command execution, file transfer, directory listing, and system monitoring.4MIT
- AlicenseAqualityDmaintenanceEnables AI tools to manage SSH connections, execute commands, transfer files, and perform remote server diagnostics via MCP protocol.1710 npmMIT