Click on "Install 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 ServerList the files in /var/www/html on the staging profile"
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
MCP (Model Context Protocol) server for remote server administration via SSH. Supports multiple profiles, remote command execution, file transfer (SFTP), and destructive command detection with audit logging.
Architecture
General Overview
graph TB
Client["Claude Desktop<br/>(or any MCP client)"]
Server["SSH MCP Server"]
MCP["MCP SDK<br/>(stdio)"]
Router["Tool Router<br/>(index.ts)"]
Security["Security Module<br/>- Dangerous cmd detection<br/>- Audit logging"]
SSH["SSH Client (ssh2)"]
Exec["exec()<br/>- Commands<br/>- cat (read)"]
SFTP["SFTP (lazy init)<br/>- upload / download<br/>- ls / write / readdir"]
Remote["Remote Server<br/>(Linux/Unix)"]
Client -->|"stdio (JSON-RPC)"| Server
Server --- MCP
MCP --> Router
Router --> Security
Router --> SSH
SSH --- Exec
SSH --- SFTP
SSH -->|"SSH (TCP :22)"| RemoteConnection and Execution Flow
flowchart TD
Start([Start]) --> ListProfiles["ssh_list_profiles<br/>View available profiles"]
ListProfiles --> Connect["ssh_connect<br/>(profile name)"]
Connect -->|Password not found| Error["Error: env var<br/>SSH_PASSWORD_NAME missing"]
Connect -->|OK| Active["Active Connection<br/>(1 profile at a time)"]
Active --> ExecBranch["ssh_exec<br/>(command)"]
Active --> SFTPBranch["SFTP operations<br/>upload / download<br/>ls / read / write"]
Active --> StatusBranch["ssh_status<br/>ssh_disconnect"]
ExecBranch --> DangerCheck{"Dangerous<br/>command?<br/>(regex)"}
DangerCheck -->|No| Execute["Execute command"]
DangerCheck -->|Yes| ConfirmCheck{"confirm:<br/>true?"}
ConfirmCheck -->|Yes| Execute
ConfirmCheck -->|No| Warning["WARNING<br/>(not executed)"]
Execute --> Audit["audit.log"]
SFTPBranch --> Audit
Warning --> AuditSecurity Flow (Dangerous Commands)
flowchart LR
Input["Command received"] --> Check["isDangerousCommand()<br/>(16 regex patterns)"]
Check -->|Safe| Exec["Execute command"]
Check -->|Dangerous| Confirm{"confirm: true?"}
Confirm -->|Yes| Exec
Confirm -->|No| Warn["WARNING returned<br/>(command NOT executed)"]
Exec --> Log["audit.log"]
Warn --> Log
subgraph Detected Patterns
P1["rm -rf /"]
P2["mkfs.*"]
P3["dd if="]
P4["reboot / shutdown / halt"]
P5["chmod 777 / chown -R"]
P6["fork bomb"]
P7["systemctl stop/disable"]
P8["killall / iptables -F"]
endProject Structure
s01_ssh_mcp/
├── src/
│ ├── index.ts # SSHMCPServer class — tool router and SSH logic
│ ├── tools.ts # MCP tool definitions (10 tools, JSON schemas)
│ ├── profiles.ts # Profile loading + password injection from env
│ ├── security.ts # Dangerous command detection + AuditLogger
│ └── types.ts # Interfaces: SSHProfile, AuditEntry
├── dist/ # Compiled output (generated by tsc)
├── profiles.json # SSH server configuration
├── .env # Passwords (not versioned)
├── audit.log # Audit log (generated at runtime)
├── package.json
└── tsconfig.jsonSetup
1. Server Profiles
Edit profiles.json:
{
"production": {
"host": "192.168.1.100",
"port": 22,
"username": "deploy"
},
"staging": {
"host": "192.168.1.101",
"port": 22,
"username": "deploy"
}
}2. Passwords
Create .env (copy from .env.example):
SSH_PASSWORD_PRODUCTION=your_password
SSH_PASSWORD_STAGING=your_passwordFormat: SSH_PASSWORD_<PROFILE_NAME_UPPERCASE>.
3. Build and Run
npm install
npm run build
npm start4. MCP Configuration (Claude Desktop)
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"ssh": {
"command": "node",
"args": ["/path/to/s01_ssh_mcp/dist/index.js"],
"env": {
"SSH_PASSWORD_PRODUCTION": "your_password",
"SSH_PASSWORD_STAGING": "your_password"
}
}
}
}Note: You can optionally set
SSH_PROFILES_PATHinenvto point to aprofiles.jsonin a different location.
Available Tools
Tool | Description | Requires Connection |
| List configured profiles (without passwords) | No |
| Connect to an SSH profile | No |
| Close the active SSH connection | Yes |
| Connection status (profile, host, uptime) | Yes |
| Execute a remote command | Yes |
| Upload a local file to the server (SFTP) | Yes |
| Download a file from the server (SFTP) | Yes |
| List a remote directory (SFTP) | Yes |
| Read remote file contents | Yes |
| Write content to a remote file (SFTP) | Yes |
Tool Parameters
Tool | Parameters | Required |
|
| Yes |
|
|
|
|
| Both |
|
| Both |
|
| No |
|
| Yes |
|
| Both |
Security
Destructive Command Detection
The following patterns are intercepted and require confirm: true to execute:
Pattern | Reason |
| Recursive rm on system root |
| Mass file deletion |
| Filesystem formatting |
| Direct disk write |
| Server state control |
| Runlevel change |
| Insecure permissions on root |
| Mass ownership change |
| Direct device write |
| Fork bomb |
| System service shutdown |
| Mass process termination |
| Firewall rules flush |
Audit Log
All operations are logged to audit.log with the format:
[timestamp] [profile] [tool] [parameters] [RESULT: ok|error]Example:
[2026-03-04T10:30:00.000Z] [production] [ssh_exec] [ls -la /var/log] [RESULT: ok]
[2026-03-04T10:31:00.000Z] [production] [ssh_upload] [./app.tar.gz -> /tmp/app.tar.gz] [RESULT: ok]Technical Details
MCP Transport: stdio (JSON-RPC over stdin/stdout)
SSH Connection: One active connection at a time. Attempting to connect to another profile without disconnecting raises an error.
SFTP: Lazy initialization — created on first file operation use and reused thereafter.
File Reading: Uses
ssh exec cat(not SFTP) for text files.File Writing: Uses SFTP
createWriteStreamfor large file support.Argument Escaping: Shell escaping with single quotes to prevent command injection.
Audit Logging: Non-blocking — log write failures are silently ignored to avoid disrupting operations.
Profile Cache:
profiles.jsonis read once and cached in memory.
License
This project is licensed under the MIT License.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.