netixc/ssh-mcp
If you are the rightful owner of ssh-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
SSH MCP Server is a local Model Context Protocol (MCP) server that provides SSH control for Linux and Windows systems, allowing LLMs and other MCP clients to execute shell commands securely via SSH.
Installation
-
Clone the repository:
git clone https://github.com/netixc/ssh-mcp.git cd ssh-mcp -
Install dependencies:
npm install"ssh-mcp": { "command": "node", "args": [ "/path/to/ssh-mcp/build/index.js", "--host=1.2.3.4", "--port=22", "--user=root", "--password=pass", "--key=path/to/key", "--timeout=30000", "--maxChars=none" ] }
Client Setup
Required Parameters:
host: Hostname or IP of the Linux or Windows serveruser: SSH username
Optional Parameters:
port: SSH port (default: 22)password: SSH password (or usekeyfor key-based auth)key: Path to private SSH keytimeout: Command execution timeout in milliseconds (default: 60000ms = 1 minute)maxChars: Maximum allowed characters for thecommandinput (default: 1000). Usenoneor0to disable the limit.strictMode: Enable command injection protection (default: false). Set totrueto block dangerous patterns.rateLimit: Enable rate limiting (default: true). Set tofalseto disable.rateLimitMax: Maximum requests per window (default: 10)rateLimitWindow: Rate limit window in milliseconds (default: 60000ms = 1 minute)auditLog: Enable audit logging (default: false). Set totrueto log all commands to stderr.debug: Enable debug mode (default: false). Set totruefor verbose logging.pool: Enable connection pooling (default: true). Set tofalseto disable.poolMaxSize: Maximum pooled connections (default: 3)poolTtl: Connection pool TTL in milliseconds (default: 300000ms = 5 minutes)
Environment Variables:
All configuration options can be set via environment variables using the SSH_MCP_ prefix:
SSH_MCP_HOST,SSH_MCP_PORT,SSH_MCP_USER,SSH_MCP_PASSWORD,SSH_MCP_KEYSSH_MCP_TIMEOUT,SSH_MCP_MAX_CHARS,SSH_MCP_STRICT_MODESSH_MCP_RATE_LIMIT,SSH_MCP_RATE_LIMIT_MAX,SSH_MCP_RATE_LIMIT_WINDOWSSH_MCP_AUDIT_LOG,SSH_MCP_DEBUGSSH_MCP_POOL,SSH_MCP_POOL_MAX_SIZE,SSH_MCP_POOL_TTL
Tools
1. exec - Execute Shell Commands
Execute any shell command on the remote server and get the output.
- Parameters:
command(required): Shell command to execute
- Use Cases: System monitoring, file management, process control, running scripts
- Examples:
- Check disk space:
df -h - View logs:
tail -f /var/log/syslog - Process management:
ps aux | grep nginx
- Check disk space:
- Configuration:
- Timeout:
--timeout=60000(default: 1 minute) - Max length:
--maxChars=1000(set tononefor unlimited) - Strict mode:
--strictMode=true(blocks dangerous patterns)
- Timeout:
2. upload - Upload Files to Server
Transfer files from your local machine to the remote server via SFTP.
- Parameters:
localPath(required): Absolute path to local fileremotePath(required): Absolute destination path on server
- Use Cases: Deploy configs, upload scripts, transfer data, push backups
- Examples:
- Upload config:
localPath=/tmp/nginx.conf,remotePath=/etc/nginx/nginx.conf - Deploy script:
localPath=./deploy.sh,remotePath=/home/user/deploy.sh
- Upload config:
- Notes: Supports files of any size, parent directory must exist
3. download - Download Files from Server
Retrieve files from the remote server to your local machine via SFTP.
- Parameters:
remotePath(required): Absolute path to remote filelocalPath(required): Absolute path where file will be saved locally
- Use Cases: Fetch logs, download backups, retrieve data files, pull configs
- Examples:
- Download log:
remotePath=/var/log/app.log,localPath=/tmp/app.log - Get backup:
remotePath=~/backup.tar.gz,localPath=./backup.tar.gz
- Download log:
- Notes: Supports files of any size, local directory must exist
4. listFiles - List Remote Directory
List all files and directories in a remote path with detailed information.
- Parameters:
remotePath(required): Absolute path to remote directory
- Use Cases: Browse filesystem, find files, verify uploads, explore directories
- Returns: File type (file/dir), size in bytes, last modified timestamp
- Examples:
- List home:
remotePath=/home/user - Browse logs:
remotePath=/var/log
- List home:
Security Features
- Command Sanitization: Validates and sanitizes all commands before execution
- Strict Mode: Optional protection against command injection (
--strictMode=true) - Rate Limiting: Configurable request rate limiting to prevent abuse
- Audit Logging: Optional logging of all executed commands with timestamps and exit codes
- Connection Pooling: Reuse SSH connections for better performance
- Environment Variable Support: Configure via environment variables instead of CLI args