mcp-ssh-gateway
Allows managing NGINX services on remote Linux servers, including starting, stopping, restarting, and checking status.
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., "@mcp-ssh-gatewayshow me the last 20 lines of /var/log/syslog"
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.
MCP SSH Gateway
A Model Context Protocol (MCP) server for managing Linux servers via SSH. This server provides tools for executing commands, managing files, monitoring services, and analyzing logs on remote Linux systems.
Installation
Docker (Recommended)
Build and run with Docker Compose:
docker compose up -dNo .env file is required. SSH_HOST and SSH_USER are defined in docker-compose.yml (with defaults), and SSH_KEY_FILE defaults to /app/ssh_keys/id_ed25519.
On first container start, the entrypoint checks for /app/ssh_keys/id_ed25519. If it does not exist, a new ed25519 key pair is generated automatically. The /app/ssh_keys folder is mounted as a Docker volume, so the key persists across restarts.
Manual Installation
Install dependencies:
pip install -r requirements.txtSet environment variables:
export SSH_HOST=your-server.example.com
export SSH_USER=root
export SSH_PASSWORD=your_password
# OR
export SSH_KEY_FILE=/path/to/private/keyRun the server:
python -m ssh_mcp_server.serverAnythingLLM Integration
Add the following configuration to your anythingllm_mcp_servers.json:
{
"mcpServers": {
"mcp-ssh-gateway": {
"name": "MCP SSH Gateway",
"type": "streamable",
"url": "http://mcp-ssh-gateway:8000/mcp",
"auth_token": null,
"enabled": true
}
}
}Related MCP server: SSH MCP Server
Configuration
Environment Variables
Variable | Description | Default |
| Target server hostname or IP |
|
| SSH username |
|
| SSH password | - |
| Path to SSH private key |
|
| SSH port |
|
| Optional bearer token for MCP HTTP auth | - |
| OAuth client ID for | - |
| OAuth client secret for | - |
| Optional external base URL for OAuth metadata endpoints | - |
| MCP server bind address |
|
| MCP server port |
|
Authentication
The server supports two authentication methods:
Password Authentication: Set
SSH_PASSWORDin your environmentKey-based Authentication: By default, Docker uses
/app/ssh_keys/id_ed25519(auto-generated on first run). You can still overrideSSH_KEY_FILEif needed.
MCP HTTP Authentication (Optional)
Set AUTH_TOKEN to require bearer authentication on all incoming MCP HTTP requests.
Header required:
Authorization: Bearer <AUTH_TOKEN>Missing or incorrect token: HTTP
401 UnauthorizedAUTH_TOKENunset: authentication is disabled and requests are allowed through
OAuth 2.0 Client Credentials
The server exposes POST /oauth/token for client credentials token exchange.
Required env vars:
CLIENT_ID,CLIENT_SECRET, andAUTH_TOKENRequest body (
application/jsonor form-encoded):client_idclient_secretoptional
grant_type=client_credentials
Success response: bearer token payload with
access_tokenequal toAUTH_TOKENInvalid credentials: HTTP
401withinvalid_clientMissing server config (
CLIENT_ID,CLIENT_SECRET, orAUTH_TOKEN): HTTP503
Usage
Basic Connection Test
# Test SSH connection
test_ssh_connection(
hostname="server.example.com",
username="root",
password="your_password"
)Execute Commands
# Execute a simple command
execute_command("ls -la /var/log")
# Execute with sudo
execute_command("systemctl status nginx", use_sudo=True)File Operations
# Read a file
read_file("/etc/nginx/nginx.conf")
# Write to a file
write_file("/tmp/test.txt", "Hello World!")
# List directory contents
list_directory("/var/log")Service Management
# Check service status
get_service_status("nginx")
# Start a service
start_service("nginx")
# Stop a service
stop_service("nginx")
# Restart a service
restart_service("nginx")Process Management
# List all processes
list_processes()
# List specific processes
list_processes(filter_by="nginx")
# Kill a process
kill_process("12345", signal="TERM")Network Tools
# Check if port is open
check_port(80)
# Get network connections
get_network_connections()Log Analysis
# Tail a log file
tail_log("/var/log/nginx/access.log", lines=100)
# Search in logs
search_log("/var/log/nginx/error.log", "error")Security Considerations
Use SSH key-based authentication when possible
Limit SSH access to specific users and IPs
Regularly rotate SSH keys and passwords
Monitor SSH access logs
Use sudo judiciously and limit sudo privileges
Troubleshooting
Connection Issues
Authentication Failed: Check username, password, or key file
Connection Refused: Verify SSH service is running and port is correct
Host Key Verification: Ensure the server's host key is trusted
Permission Issues
File Access Denied: Check file permissions and ownership
Sudo Required: Use
use_sudo=Truefor privileged operationsService Management: Ensure user has appropriate systemd permissions
Performance Issues
Slow Commands: Increase timeout values for long-running commands
Connection Timeouts: Check network connectivity and server load
Resource Usage: Monitor server resources during operations
API Reference
The server exposes the following MCP tools:
test_ssh_connection: Test SSH connectivityget_server_info: Get system informationexecute_command: Execute commandsread_file: Read file contentswrite_file: Write file contentslist_directory: List directory contentsget_service_status: Check service statusstart_service: Start a servicestop_service: Stop a servicerestart_service: Restart a servicelist_processes: List running processeskill_process: Kill a processcheck_port: Check port statusget_network_connections: Get network connectionstail_log: Tail log filessearch_log: Search log files
License
This project is licensed under the MIT License.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Danvic-DEV/mcp-ssh-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server