Back to MCP directory
publicPublicdnsLocal runtime

m2m-mcp-server-ssh-server

MCP SSH服务器是一个安全的远程访问工具,允许客户端通过SSH协议连接并交互多个MCP工具服务。它支持密钥认证、提供密钥管理API,并能聚合多个MCP服务器为统一接口。

article

README

🚀 MCP 服务器 SSH

MCP 服务器 SSH 是一款用于提供安全 SSH 访问的工具,具备密钥管理功能。它支持客户端通过 SSH 协议连接服务器,还能借助配套的 HTTP 密钥管理服务器,简化客户端公钥的注册流程。

🚀 快速开始

MCP 服务器 SSH 能让你安全地进行 SSH 连接,并通过密钥管理服务器简化公钥注册。你可以按照以下步骤开始使用。

✨ 主要特性

  • 提供安全的 SSH 访问。
  • 支持密钥管理功能,可简化客户端公钥注册流程。
  • 可选择性运行 HTTP 密钥管理服务器。
  • 默认绑定到 localhost 提高安全性。
  • 自动生成具有安全权限的密钥。
  • 支持客户端 IP 地址白名单限制。

📦 安装指南

使用命令行运行

uv run m2m-mcp-server-ssh-server --help

参数选项

| 参数 | 详情 | | ---- | ---- | | --host | SSH 服务器绑定的主机地址,默认为 127.0.0.1 | | --port | SSH 服务器监听的端口,默认为 8022 | | --authorized-clients | 授权客户端密钥文件路径,默认为 ~/.ssh/authorized_keys | | --server-key | 服务器私钥文件路径,默认为 ~/.ssh/m2m_mcp_server_ssh_server | | --passphrase | 私钥密码(可选) | | --servers-config | 服务器配置 JSON 文件路径,默认为 servers_config.json | | --log-level | 设置日志级别,默认为 INFO | | --run-key-server | 运行 HTTP 密钥管理服务器 | | --key-server-port | HTTP 密钥管理服务器的端口,默认为 8000 | | --key-server-host | HTTP 密钥管理服务器的主机,默认为 127.0.0.1 | | --version | 显示版本信息并退出 |

⚠️ 重要提示

当绑定到所有接口(0.0.0.0)时,您的服务器将可以从能够访问您系统的任何机器访问。请确保使用强身份验证,并考虑使用防火墙等额外安全措施。

💻 使用示例

密钥管理服务器

您可以选择性地运行一个 HTTP 密钥管理服务器来简化客户端密钥注册:

uv run m2m-mcp-server-ssh-server --run-key-server

这将启动:

  • SSH 服务器监听 8022 端口
  • 密钥管理 HTTP 服务器监听 8000 端口(默认仅限 localhost)

密钥管理 API

密钥管理服务器提供以下接口:

基础用法

# 注册客户端公钥
curl -X POST -H "Content-Type: application/json" \
  -d '{"client_pub_key": "ssh-rsa AAAA..."}' \
  http://localhost:8000/register

上述代码展示了如何使用 curl 命令向密钥管理服务器注册客户端公钥。

高级用法

# 获取服务器的公钥
curl http://localhost:8000/server_pub_key

# 检查服务器健康状态
curl http://localhost:8000/health

上述代码展示了如何使用 curl 命令获取服务器的公钥和检查服务器的健康状态。

接口详情

  1. POST /register - 注册客户端公钥

    • 请求体:{"client_pub_key": "ssh-rsa AAAA..."}
    • 响应:{"status": "success"} 或错误信息
  2. GET /server_pub_key - 获取服务器的公钥

    • 响应:{"server_pub_key": "ssh-ed25519 AAAA..."}
  3. GET /health - 检查服务器健康状态

    • 响应:{"status": "healthy"}

🔧 技术细节

安全注意事项

  • 默认绑定到 localhost(127.0.0.1)以提高安全性。
  • 自动生成具有安全权限的密钥(如果没有提供)。
  • 默认密钥位置为 ~/.ssh/m2m_mcp_server_ssh_server
  • 私钥使用 0644 权限进行保护。
  • 支持客户端 IP 地址白名单限制。

依赖项

  • Python 3.8+
  • pip 包管理器
  • cryptography 库(用于加密操作)

开发环境设置

git clone https://github.com/yourusername/mcp-server-ssh.git
cd mcp-server-ssh
pip install -r requirements.txt
python main.py --help

🤝 贡献指南

提交代码

  1. Fork 项目仓库。
  2. 创建功能分支:git checkout -b feature/new-feature
  3. 提交更改:git commit -m "添加新功能"
  4. 推送到分支:git push origin feature/new-feature
  5. 创建 Pull Request。

开发规范

  1. 遵循 PEP8 代码风格指南。
  2. 添加单元测试用例。
  3. 确保文档更新。
  4. 提交前运行格式检查:black .

📄 许可证

本项目采用 MIT 许可证,详见 LICENSE 文件。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client