cygnus ssh-mcp
用于AI助手的最强大的SSH MCP服务器
](https://pypi.org/project/cygnus-ssh-mcp/)   
*使用43个专用工具让Claude完全控制您的Linux、macOS和Windows服务器*
______________________________________________________________________
为什么选择cygnus ssh-mcp?
大多数SSH MCP服务器允许您运行命令。 cygnus ssh-mcp 让你 *管理服务器*.
| 您将获得什么 | 基本SSH MCP | cygnus SSH-MCP |
|---|---|---|
| 运行命令 | ✅ | ✅ |
| 带有别名的预配置主机 | ❌ | ✅ |
| Sudo支持(Linux/macOS) | 有限 | ✅ |
| Windows服务器支持 | ❌ | ✅ |
| 后台任务管理 | ❌ | ✅ |
| 行级文件编辑 | ❌ | ✅ |
| 带有输出的命令历史记录 | ❌ | ✅ |
| 递归目录操作 | ❌ | ✅ |
| 存档创建/提取 | ❌ | ✅ |
| 完全支持Unicode | ? | ✅ |
______________________________________________________________________
安装
pip install cygnus-ssh-mcp或者使用不安装的方式运行 uvx:
uvx cygnus-ssh-mcp______________________________________________________________________
快速开始
1.创建hosts文件
创建 ~/.mcp_ssh_hosts.toml:
# Minimal (password auth) - only required fields
["user@server.example.com"]
password = "your_password"
port = 22
# With alias and sudo (most common setup)
["admin@production.example.com"]
password = "your_password"
port = 22
sudo_password = "sudo_pass" # optional: for use_sudo operations
alias = "prod" # optional: connect by alias
description = "Production server" # optional: for documentation
# SSH key authentication
["deploy@staging.example.com"]
keyfile = "~/.ssh/id_ed25519"
port = 22
alias = "staging"
# Windows Server (requires OpenSSH)
["administrator@winserver.example.com"]
password = "your_password"
port = 22
alias = "win-prod"必填字段: port + (password 或 keyfile) 可选字段: alias, description, sudo_password, key_passphrase
主机文件位置: 默认值为~/.mcp_ssh_hosts.toml.回落到./mcp_ssh_hosts.toml如果没有找到。 使用--config /path/to/hosts.toml用于自定义位置。
2.添加到克劳德桌面
编辑您的 claude_desktop_config.json:
{
"mcpServers": {
"ssh": {
"command": "cygnus-ssh-mcp"
}
}
}或者使用自定义主机文件位置:
{
"mcpServers": {
"ssh": {
"command": "cygnus-ssh-mcp",
"args": ["--config", "/path/to/my_hosts.toml"]
}
}
}3.开始管理服务器
在克劳德,只需说:
“连接到prod并显示磁盘使用情况”
“编辑/etc/nginx/nginx.conf并将worker_connections更改为2048”
“在/var/log中查找所有大于100MB的.log文件”
______________________________________________________________________
平台支持
cygnus ssh-mcp工作于 任何客户 (Windows、Linux、macOS) 任何目标服务器:
| 从(客户端) | 到(目标) | 状态 |
|---|---|---|
| Windows | Linux | ✅ 已测试 |
| Windows | Windows | ✅ 已测试 |
| Linux | Linux | ✅ 已测试 |
| Linux | Windows | ✅ 已测试 |
| macOS | 任何 | ✅ 支持 |
Windows目标 需要安装并运行OpenSSH服务器。
______________________________________________________________________
特性
主机配置
停止键入凭据。通过别名连接。
["admin@server.com"]
password = "secret"
port = 22
alias = "web"那么,只需: *“连接到网络”*
支持 密码, SSH密钥,以及 带密码的加密密钥.
______________________________________________________________________
行级文件编辑
以外科手术般的精确度编辑配置文件——无需下载/上传。
# Replace a single line
ssh_file_replace_line(
file_path="/etc/nginx/nginx.conf",
match_line="worker_connections 1024;",
new_line="worker_connections 4096;"
)
# Insert lines after a match
ssh_file_insert_lines_after_match(
file_path="/etc/hosts",
match_line="# Custom entries",
lines_to_insert=["192.168.1.10 app.local", "192.168.1.11 db.local"]
)内置安全功能:如果匹配不是唯一的,则操作失败——没有意外的大规模编辑。
______________________________________________________________________
后台任务管理
启动长时间运行的流程,稍后再检查。
# Start a backup (returns immediately)
ssh_task_launch(command="./backup.sh", stdout_log="/var/log/backup.log")
# Check status anytime
ssh_task_status(pid=12345) # → 'running' or 'exited'
# Kill if needed
ssh_task_kill(pid=12345, force=True)______________________________________________________________________
全面的Sudo支持
每个工具都支持 use_sudo。密码会自动处理。
ssh_file_write(path="/etc/app/config.yaml", content="...", use_sudo=True)
ssh_dir_mkdir(path="/opt/myapp", use_sudo=True)
ssh_archive_extract(archive="/backup.tar.gz", dest="/", use_sudo=True)______________________________________________________________________
双超时系统
永远不要被挂起的命令困住。
ssh_cmd_run(
command="./long_script.sh",
io_timeout=60.0, # Kill if no output for 60s
runtime_timeout=3600.0 # Kill if total time exceeds 1 hour
)______________________________________________________________________
完全支持Unicode
使用表情符号、国际文本和特殊字符写入和读取文件 所有平台.
✅ ❌ 🎉 • → ≥ ∞ │ ┌ ─ 你好 مرحبا Привет café naïve它是如何工作的: ssh_file_read 和 ssh_file_write 使用SFTP进行直接二进制传输,完全绕过shell编码问题。这意味着Unicode即使在PowerShell的控制台编码通常会损坏特殊字符的Windows目标上也能完美工作。
______________________________________________________________________
Windows服务器支持
OpenSSH Server完全支持Windows目标:
- PowerShell和CMD 命令执行
- Windows路径处理 (反斜杠、驱动器号、UNC路径)
- 管理员检测 --显示会话是否具有提升的权限
- 基于SFTP的文件操作 --Unicode安全,无编码问题
注: use_sudo 在Windows上被忽略(没有等效的sudo)。对于提升的操作,请使用管理员帐户连接。
______________________________________________________________________
还有更多。..
- 命令历史记录 具有输出保留和模式过滤功能
- 递归目录操作:使用模拟运行搜索、复制、删除
- 归档操作:创建并提取tar.gz
- 系统信息:操作系统版本、内存、磁盘、CPU、正常运行时间
- 模式搜索:文件中的正则表达式和纯文本
______________________________________________________________________
全部43个工具
连接和主机管理(10个工具)
| 工具 | 说明 |
|---|---|
ssh_conn_connect | 使用预配置的主机进行连接(通过密钥或别名) |
ssh_conn_is_connected | 检查SSH连接是否处于活动状态 |
ssh_conn_status | 获取连接状态(用户、主机、操作系统、cwd) |
ssh_conn_host_info | 获取详细的系统信息 |
ssh_conn_verify_sudo | 验证sudo访问权限 |
ssh_conn_add_host | 将新主机添加到配置中 |
ssh_host_list | 列出所有已配置的主机 |
ssh_host_remove | 从配置中删除主机 |
ssh_host_disconnect | 断开当前会话 |
list_tools | 列出所有可用工具 |
命令执行(6个工具)
| 工具 | 说明 |
|---|---|
ssh_cmd_run | 执行带有I/O和运行时超时的命令 |
ssh_cmd_kill | 终止运行命令 |
ssh_cmd_check_status | 检查命令状态 |
ssh_cmd_output | 从命令中检索输出 |
ssh_cmd_history | 通过筛选获取命令历史记录 |
ssh_cmd_clear_history | 清除命令历史记录 |
后台任务(3个工具)
| 工具 | 说明 |
|---|---|
ssh_task_launch | 在后台启动命令 |
ssh_task_status | 检查任务是否正在运行 |
ssh_task_kill | 向任务发送信号 |
文件操作(12个工具)
| 工具 | 说明 |
|---|---|
ssh_file_stat | 获取文件元数据 |
ssh_file_read | 通过SFTP读取文件内容(Unicode安全) |
ssh_file_write | 创建/覆盖/附加文件 |
ssh_file_copy | 复制文件 |
ssh_file_move | 移动或重命名文件 |
ssh_file_transfer | 上传或下载文件 |
ssh_file_find_lines_with_pattern | 在文件中搜索图案 |
ssh_file_get_context_around_line | 获取比赛的背景信息 |
ssh_file_replace_line | 更换单线 |
ssh_file_replace_line_multi | 用多条线替换 |
ssh_file_insert_lines_after_match | 匹配后插入线条 |
ssh_file_delete_line_by_content | 按内容删除行 |
目录操作(10个工具)
| 工具 | 说明 |
|---|---|
ssh_dir_mkdir | 创建目录 |
ssh_dir_remove | 删除目录 |
ssh_dir_list_files_basic | 基本目录列表 |
ssh_dir_list_advanced | 带有元数据的递归列表 |
ssh_dir_search_glob | 按模式搜索文件 |
ssh_dir_search_files_content | 在文件中搜索文本 |
ssh_dir_calc_size | 计算目录大小 |
ssh_dir_delete | 使用模拟运行支持删除 |
ssh_dir_batch_delete_files | 按模式批量删除 |
ssh_dir_copy | 递归复制目录 |
归档操作(2个工具)
| 工具 | 说明 |
|---|---|
ssh_archive_create | 创建tar.gz存档 |
ssh_archive_extract | 提取存档 |
______________________________________________________________________
文档
详细指南可在 docs/:
______________________________________________________________________
用例
- DevOps自动化 --通过人工智能部署、配置和管理服务器
- 日志分析 --跨多个服务器搜索和分析日志
- 配置管理 --使用精确行操作编辑配置
- 备份和恢复 --创建档案、传输文件、还原备份
- 系统监控 --检查状态、验证服务、监控流程
- 安全审计 --搜索敏感模式,验证配置
______________________________________________________________________
许可证
GPL-3.0 --免费和开源。
______________________________________________________________________
建造于 天鹅座系统
*如果你觉得这个仓库有用,就把它标上!*
