SSH MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
SSH MCP Server
A Model Context Protocol (MCP) server that enables AI agents like Claude Code and Cursor to execute commands on remote servers via persistent SSH sessions. Built with Bun and Hono for high performance and ease of deployment.
Overview
This MCP server provides a secure, stateful SSH interface for AI-powered development tools. It maintains persistent SSH connections in memory, allowing agents to execute commands across sessions without requiring any software installation on remote hosts.
Key Benefits:
Zero Installation: No agent software needed on remote servers
Stateful Sessions: Maintain context across multiple commands (e.g.,
cdfollowed byls)Dual Transport: Works as both an HTTP service and stdio-based command
Secure by Default: Key-based authentication with automatic session cleanup
Related MCP server: Remote SSH MCP
Features
Persistent SSH Sessions: Powered by
ssh2with automatic idle cleanup after 30 minutesThree Simple Tools:
ssh_open,ssh_exec, andssh_closefor complete session controlFlexible Transport: HTTP endpoint (
POST /mcp) or stdio for command-based MCP clientsLightweight & Fast: Built on Bun runtime and Hono web framework
Container Ready: Pre-built Docker images available on GitHub Container Registry
Quick Start
Using Docker (Recommended)
Pull the pre-built image:
docker pull ghcr.io/kiyo-e/ssh-mcp-server:latestRun in stdio mode for MCP clients:
docker run --rm -i ghcr.io/kiyo-e/ssh-mcp-server:latestWith SSH key authentication:
docker run --rm -i \
-e SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" \
ghcr.io/kiyo-e/ssh-mcp-server:latestLocal Development
Install dependencies:
bun installStart the server:
# HTTP mode (default port 3000)
bun run start:http
# STDIO mode for command-based MCP clients
bun run start:stdioMCP Tools
This server exposes three tools for managing SSH sessions:
Tool | Description | Parameters |
| Opens a new SSH session with password or key-based auth |
|
| Executes a command on an existing session |
|
| Closes an active session and frees resources |
|
Example Workflow
// 1. Open a session
const session = await ssh_open({
host: "example.com",
username: "deploy",
port: 22
});
// 2. Execute commands (maintains state)
await ssh_exec({ sessionId: session.id, command: "cd /var/www" });
await ssh_exec({ sessionId: session.id, command: "ls -la" });
// 3. Close when done
await ssh_close({ sessionId: session.id });Configuration
For Claude Code
Quick Setup (Using Docker):
# Add the MCP server using Claude Code CLI
claude mcp add ssh-mcp docker run --rm -i ghcr.io/kiyo-e/ssh-mcp-server:latestWith SSH key authentication:
# Add with SSH_PRIVATE_KEY environment variable
claude mcp add ssh-mcp docker run --rm -i -e SSH_PRIVATE_KEY ghcr.io/kiyo-e/ssh-mcp-server:latest \
--env SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)"Or manually edit your Claude Code configuration file (~/.config/claude/claude_desktop_config.json):
{
"mcpServers": {
"ssh-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"ghcr.io/kiyo-e/ssh-mcp-server:latest"
]
}
}
}With SSH key (manual configuration):
{
"mcpServers": {
"ssh-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"SSH_PRIVATE_KEY",
"ghcr.io/kiyo-e/ssh-mcp-server:latest"
],
"env": {
"SSH_PRIVATE_KEY": "$(cat ~/.ssh/id_rsa)"
}
}
}
}For OpenAI Codex
Add to your Codex MCP configuration:
# Add via command line
codex mcp add ssh-mcp docker run --rm -i ghcr.io/kiyo-e/ssh-mcp-server:latestWith SSH key authentication:
# Add with SSH_PRIVATE_KEY environment variable
codex mcp add ssh-mcp docker run --rm -i -e SSH_PRIVATE_KEY ghcr.io/kiyo-e/ssh-mcp-server:latest \
--env SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)"Or manually configure:
{
"mcpServers": {
"ssh-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"ghcr.io/kiyo-e/ssh-mcp-server:latest"
]
}
}
}With SSH key (manual configuration):
{
"mcpServers": {
"ssh-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"SSH_PRIVATE_KEY",
"ghcr.io/kiyo-e/ssh-mcp-server:latest"
],
"env": {
"SSH_PRIVATE_KEY": "$(cat ~/.ssh/id_rsa)"
}
}
}
}For HTTP Transport
{
"mcpServers": {
"ssh-mcp": {
"type": "http",
"url": "http://localhost:3000/mcp"
}
}
}Environment Variables
Variable | Description | Required |
| Private key content for key-based authentication | No* |
| HTTP server port (default: 3000) | No |
*Required if not using password authentication with ssh_open
Advanced Usage
Custom Port Configuration
# HTTP mode with custom port
PORT=4000 bun run src/index.ts
# Docker with custom port
docker run --rm -p 4000:4000 \
-e PORT=4000 \
-e SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" \
ghcr.io/kiyo-e/ssh-mcp-server:latestSandboxed Environment Installation
If Bun cannot write to your temp directory (common in sandboxed environments):
TMPDIR=$(pwd)/.tmp bun installBuilding from Source
# Clone the repository
git clone https://github.com/kiyo-e/ssh-mcp-server.git
cd ssh-mcp-server
# Install dependencies
bun install
# Build Docker image
docker build -t ssh-mcp-server .Best Practices
Session Management: Always call
ssh_closewhen done to free resources immediatelyIdle Timeout: Sessions automatically expire after 30 minutes of inactivity
Stateful Commands: Take advantage of persistent shells for multi-step operations (e.g.,
cdthenls)Security: Use key-based authentication when possible; avoid hardcoding passwords
Requirements
Runtime: Bun v1.1+ (for local development)
Container: Docker (optional but recommended)
SSH Access: Valid credentials for target remote hosts
Links
Repository: github.com/kiyo-e/ssh-mcp-server
Container Images: ghcr.io/kiyo-e/ssh-mcp-server
Issues: Report bugs or request features
License
MIT License - see LICENSE file for details.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Scoped, audited SSH exec, sessions, and SFTP on your saved servers without exposing credentials
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to have persistent, fully interactive SSH sessions into remote hosts, behaving like a local terminal.9 npm2MIT
- AlicenseAqualityBmaintenanceExposes persistent, stateful remote Bash sessions to AI agents via SSH, enabling command execution with preserved working directory and environment.764 npm1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to securely execute commands on remote hosts via SSH and SFTP, with persistent shells, file transfers, screenshots, and an audit log.5MIT
- AlicenseAqualityCmaintenanceEnables AI agents to establish and manage persistent SSH sessions, supporting smart command execution, async tasks, multi-host, sudo, and file operations through SFTP.15MIT