mcp-server-ssh
by: shaike1
mcp server ssh
📌Overview
Purpose: To provide a robust SSH server implementation for secure remote command execution and file operations using the Model Context Protocol (MCP).
Overview: The MCP SSH Server is designed to facilitate secure interactive communication and file management over SSH, supporting various authentication mechanisms. This solution enhances productivity by enabling users to perform command executions and file transfers efficiently.
Key Features:
-
Secure SSH connection management: Ensures safe and encrypted connections for data transmission.
-
Password and key-based authentication: Offers flexibility in user authentication methods to enhance security based on user preferences.
-
Remote command execution: Allows users to execute commands on remote servers seamlessly.
-
File operations (upload/download): Facilitates easy file management by enabling both uploading and downloading of files.
-
Progress tracking for file transfers: Provides real-time feedback on the status of ongoing file transfers to enhance user experience.
-
Permission management: Ensures that proper access controls are in place for enhanced security.
-
Directory operations: Enables users to manage directories with actions such as listing contents.
-
Bulk file transfers: Supports efficient multiple file transfers to save time and bandwidth.
-
Detailed logging: Keeps thorough records of operations for monitoring and auditing purposes.
MCP SSH Server
A powerful SSH server implementation for Model Context Protocol (MCP). This server enables secure remote command execution and file operations through SSH protocol, supporting both password and key-based authentication.
Features
- Secure SSH connection management
- Password and key-based authentication
- Remote command execution
- File operations (upload/download)
- Progress tracking for file transfers
- Permission management
- Directory operations
- Bulk file transfers
- Detailed logging
Installation
- Install the package:
npm install mcp-ssh
- Add to your Claude desktop config (
claude_desktop_config.json
):
{
"mcpServers": {
"ssh": {
"command": "node",
"args": ["%APPDATA%/npm/node_modules/mcp-ssh/dist/server.js"],
"env": {
"SSH_PORT": "8889",
"SSH_LOG_LEVEL": "info"
}
}
}
}
Usage
Password Authentication
$body = @{
id = "test"
host = "example.com"
port = 22
username = "user"
password = "pass123"
} | ConvertTo-Json
Invoke-RestMethod -Uri "http://localhost:8889/connect" -Method Post -Body $body -ContentType "application/json"
Key Authentication
$body = @{
id = "test"
host = "example.com"
port = 22
username = "user"
privateKey = Get-Content ~/.ssh/id_rsa | Out-String
passphrase = "optional-key-passphrase"
} | ConvertTo-Json
Invoke-RestMethod -Uri "http://localhost:8889/connect" -Method Post -Body $body -ContentType "application/json"
Execute Commands
$execBody = @{
id = "test"
command = "ls -la"
} | ConvertTo-Json
Invoke-RestMethod -Uri "http://localhost:8889/exec" -Method Post -Body $execBody -ContentType "application/json"
File Operations
# Upload file
$uploadForm = @{
file = Get-Item -Path "localfile.txt"
remotePath = "/remote/path/file.txt"
}
Invoke-RestMethod -Uri "http://localhost:8889/upload/test" -Method Post -Form $uploadForm
# Download file
Invoke-RestMethod -Uri "http://localhost:8889/download/test?remotePath=/remote/path/file.txt" -Method Get -OutFile "downloaded.txt"
Directory Operations
# List directory
Invoke-RestMethod -Uri "http://localhost:8889/ls/test?path=/remote/path" -Method Get
# Get connection status
Invoke-RestMethod -Uri "http://localhost:8889/status/test" -Method Get
Development
- Clone the repository:
git clone https://github.com/shaike1/mcp-server-ssh.git
cd mcp-server-ssh
- Install dependencies:
npm install
- Build:
npm run build
- Start server:
npm start
Environment Variables
SSH_PORT
: Server port (default: 8889)SSH_LOG_LEVEL
: Logging level (default: info)
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
MIT