
ssh-mcp
io.github.gelse由 GitHub 帳號 gelse 發布v0.3.0更新於 Oct 24, 2026
MCP gateway for controlled SSH access with per-client auth, command policies, and audit logging.
概覽
一個集中式 MCP 閘道,讓 AI 助理以受控方式透過 SSH 存取遠端伺服器,並提供依用戶端授權、命令政策與稽核記錄。
- 可以做什麼
- 透過 Streamable HTTP 提供六個 MCP 工具:列出已設定的 SSH 目標、查看某目標允許的命令、在遠端伺服器上執行命令、測試 SSH 連線,以及透過 SFTP 下載或上傳單一檔案。授權、限流、連線池與 JSONL 稽核記錄都在閘道中集中處理,而不是由每個用戶端各自管理。設定存放在 JSON 檔案中並支援熱重載,還可選配網頁儀表板與 REST API 來管理設定。
- 適用情境
- 當多個 AI 代理或用戶端需要存取同一批伺服器,而你希望在一處定義每個用戶端可執行哪些命令、重複使用連線並保留稽核紀錄時,適合使用。若需要互動式 shell、目錄列表或遞迴 SFTP 傳輸,或需要網路層存取控制,則不適合。
- 執行需求
- 以本機程序或 Docker 容器執行(映像 ghcr.io/gelse/ssh-mcp,主機連接埠 9080 對應到 8080)。需要設定目錄(CONFIG_DIR),其中包含 ssh-mcp-config.json 與 secrets.json;需要帶憑證或金鑰的 SSH 目標清單;需要為用戶端產生 API 金鑰雜湊,並透過 X-API-Key 或 Authorization: Bearer 傳入。選用:CONFIG_API_ENABLED 與 CONFIG_API_TOKEN 用於設定 API 與儀表板,LOG_DIR 用於稽核記錄。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 ssh-mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
ssh-mcp
A centralized MCP gateway that gives AI agents controlled SSH access over Streamable HTTP.
[License: MIT] [Docker] [MCP] [Security] [M8ven Live Monitored]
What problem does this solve?
Most MCP SSH servers run as local stdio processes — one per client, with no shared state, no centralized authorization, and no audit trail. When multiple AI agents need SSH access, each manages its own SSH keys and runs its own process. This creates:
- No centralized access control — every client decides what it can run
- No audit trail — commands are invisible to the ops team
- SSH key sprawl — keys scattered across every agent machine
- No rate limiting — a runaway agent can overwhelm a target
ssh-mcp solves this by deploying a single HTTP gateway. All clients connect to it; it connects to your SSH targets. Authorization, rate limiting, connection pooling, and audit logging happen in one place.
Quick Start
Using the pre-built image (recommended)
The image is published at ghcr.io/gelse/ssh-mcp:latest.
The compose file maps host port 9080 to container port 8080.
Verify the server is running:
Create a minimal config in config/ssh-mcp-config.json:
Generate an API key hash and add it to your config or
secrets.json (see Configuration).
Build locally instead
What you can do (tools)
Six MCP tools are available over Streamable HTTP:
Tool Naming Convention
All tools follow the pattern ssh_<verb>_<noun>:
ssh_list_servers— list resourcesssh_list_allowed_commands— list permissionsssh_execute_command— perform an actionssh_check_connection— verify connectivityssh_download_file/ssh_upload_file— file transfer
See examples/README.md for usage examples
including curl commands and Python client code.
What's configurable
ssh-mcp is configured via JSON files with hot-reload (15 s poll, 2 s debounce). Key areas:
Full reference: docs/CONFIGURATION.md
Why not just raw SSH / other MCP servers?
ssh-mcp adds a layered authorization chain (9 ordered layers) between every client request and every SSH command. Per-API-key and per-network rules let different agents get different permissions on different servers — without touching the underlying SSH accounts.
Additional protections:
- Circuit breakers isolate failing targets with exponential backoff
- Rate limiting prevents runaway agents from overwhelming hosts
- Structured audit logs trace every command, client, IP, and authorization decision
- Connection pooling reuses SSH sessions across requests
- Input sanitization and dangerous-pattern detection block shell injection attempts
Architecture: ARCHITECTURE.md
Security model: docs/SECURITY.md
What it is NOT
- Not an interactive shell — commands are executed individually with structured output
- Not a file manager — SFTP supports single-file download and upload only (no directory listing or recursive transfer)
- Not a firewall / network ACL — authorization is command-level, not network-level
- Does not reduce SSH account privileges — if a command is allowed, the SSH user executes it with whatever privileges that account has
Not yet / known gaps
Fixable with contribution:
- SFTP is single-file only — no directory listing or recursive transfer
- No TLS termination — run Traefik or nginx in front
- No OAuth or mTLS app-layer authentication
- Rate limiter settings are not hot-reloadable (set at boot)
Architectural:
- Config API dashboard login sessions are in-memory only — they don't survive restarts and the API is single-instance (config changes themselves persist to the config file normally)
- No tamper protection for audit logs
Observability
- Health:
GET /health— returns{"status": "ok"} - Metrics:
GET /metrics— Prometheus exposition format - Logging: Structured JSONL with request correlation
Full reference: docs/OBSERVABILITY.md
Config API & Dashboard
An optional web dashboard for managing configuration without
editing JSON files. Enable with CONFIG_API_ENABLED=true.
Full reference: docs/CONFIG-API.md
FAQ
Dashboard returns 401 over HTTP
The session cookie defaults to Secure (HTTPS only). For local
HTTP testing, set:
Then restart the container.
How do MCP clients connect?
Connect to http://host:9080/mcp using the Streamable HTTP
transport. Pass your API key via X-API-Key or
Authorization: Bearer header.
How do I generate an API key hash?
Or use the hash utility in the Config API dashboard.
How does hot reload work?
The config file is polled every 15 seconds with a 2-second debounce. Changes to targets, commands, and settings take effect without restart. Rate limiter and log target settings require a restart.
Why was my command denied?
Commands are evaluated through a 9-layer authorization chain.
The matched_via field in logs shows which layer denied.
See Security Model for the full chain.
How does rate limiting work?
Per-IP sliding window, default 60 requests per 60 seconds.
Exceeding the limit returns HTTP 503. Configure via
settings.rate_limit in the config file.
Where do logs go?
Logs are written to the /logs volume (mapped from ./logs).
The active log file is ssh-mcp.log in JSONL format with
optional gzip rotation.
Troubleshooting basics
Documentation
Development
See CONTRIBUTING.md for the full development
guide, coding conventions, and PR workflow.
Roadmap
No public roadmap. See Not yet / known gaps for current limitations and opportunities.
License
來源:README.md,提交 ec87fab
工具
0版本歷史
1- v0.3.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分