SSH Model Context Protocol Server - Enable SSH functionality for AI models
SSH Model Context Protocol Server - Enable SSH functionality for AI models
The SSH LICCO MCP server provides extensive remote SSH capabilities with a reasonable security architecture, but has several notable concerns. The codebase demonstrates security-aware design (command validation, audit logging, rate limiting) and properly scopes permissions to SSH operations. However, there are significant gaps in credential handling, incomplete input validation, and dangerous command patterns that are blocked but illustrate potential risks. The server's ability to execute arbitrary remote commands—while necessary for its purpose—requires careful deployment and configuration to avoid misuse. Supply chain analysis found 7 known vulnerabilities in dependencies (1 critical, 4 high severity). Package verification found 1 issue.
4 files analyzed · 18 issues found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
This plugin requests these system permissions. Most are normal for its category.
Set these up before or after installing:
Environment variable: SSH_HOST
Environment variable: SSH_USER
Environment variable: SSH_PASSWORD
Environment variable: SSH_PORT
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-echoqili-ssh-licco": {
"env": {
"SSH_HOST": "your-ssh-host-here",
"SSH_PORT": "your-ssh-port-here",
"SSH_USER": "your-ssh-user-here",
"SSH_PASSWORD": "your-ssh-password-here"
},
"args": [
"-y",
"ssh-licco"
],
"command": "npx"
}
}
}From the project's GitHub README.
让 AI 帮你操作服务器! 通过自然语言对话,AI 可以帮你执行命令、管理文件、查看日志、部署应用等。
npx ssh-licco
首次运行自动完成:检测 Python → 创建虚拟环境 → 安装依赖 → 启动 MCP 服务器。无需手动安装任何东西。
pip install ssh-licco
⚠️ Anaconda 用户注意:如果使用 conda 环境,推荐用
npx方式安装(完全隔离),或创建专用 conda 环境安装。直接在 base 环境pip install可能导致依赖冲突。详见 Anaconda 环境指南。
git clone https://github.com/Echoqili/ssh-licco.git
cd ssh-licco
pip install -e .
Python 版本要求: Python 3.10+
ssh-licco 采用 三层架构 实现零配置启动:
用户 → npx ssh-licco
↓
┌──── ssh-licco.js (Node 层) ────┐
│ ① 查找 Python 3.10+ │
│ ② 检测 Anaconda 环境 │
│ ③ 创建/复用 ~/.ssh-licco-venv │
│ ④ pip install 安装 │
│ ⑤ 验证依赖完整性 │
└──────────┬────────────────────┘
↓
┌── cli.py (Python 入口) ──────┐
│ 只负责启动 MCP 服务器 │
└──────────┬────────────────────┘
↓
┌── SSHMCPServer (MCP 服务) ──┐
│ 提供 SSH 连接、命令执行等 │
└────────────────────────────┘
| 特性 | 说明 |
|---|---|
| Anaconda 自动检测 | 检测 conda 环境,使用独立 venv 避免冲突 |
| 依赖完整性检查 | 每次启动验证所有依赖可导入,缺失则自动修复 |
| 增量更新 | 已有 venv 时不删除,直接 pip install -e . 增量安装 |
| 自动修复 | 依赖损坏时自动重新安装,无需手动干预 |
| npm postinstall | install.js 自动检测已有 venv,跳过删除重建 |
打开设置 → MCP → 添加新服务器:
{
"mcpServers": {
"ssh": {
"command": "ssh-licco"
}
}
}
首次启动会自动安装所有依赖,稍等片刻即可使用。
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_HOST": "192.168.1.100",
"SSH_USER": "root",
"SSH_PASSWORD": "your_password",
"SSH_PORT": "22",
"SSH_TIMEOUT": "60",
"SSH_KEEPALIVE_INTERVAL": "30",
"SSH_SESSION_TIMEOUT": "7200",
"SSH_CLIENT_TYPE": "common"
}
}
}
}
环境变量说明:
SSH_HOST: SSH 服务器地址SSH_USER: 用户名SSH_PASSWORD: 密码SSH_PORT: 端口(默认 22)SSH_TIMEOUT: 连接超时(秒)SSH_KEEPALIVE_INTERVAL: 保活间隔(秒)SSH_SESSION_TIMEOUT: 会话超时(秒)SSH_CLIENT_TYPE: SSH 客户端类型(可选,默认 common)
common - paramiko(稳定可靠,推荐)⭐performance - asyncssh(高性能,适合高并发)🚀development - fabric(简化 API,适合快速开发)👨💻启动后,系统会提示输入连接信息:
python -m ssh_mcp.server
重要:从 v0.2.1 开始,ssh-licco 提供多级安全策略,可根据使用场景灵活配置。
| 级别 | 名称 | 适用场景 | 安全评分 |
|---|---|---|---|
| STRICT | 严格模式 | 生产环境、公共服务器 | 最高 ⭐⭐⭐ |
| BALANCED | 平衡模式 | 开发环境、个人服务器(默认) | 高 ⭐⭐ |
| RELAXED | 宽松模式 | 测试环境、完全信任的服务器 | 中等 ⭐ |
Windows PowerShell:
$env:SSH_SECURITY_LEVEL = "balanced"
$env:SSH_EXTRA_ALLOWED_COMMANDS = "git,pip,npm"
npx ssh-licco
Linux/Mac:
export SSH_SECURITY_LEVEL="balanced"
export SSH_EXTRA_ALLOWED_COMMANDS="git,pip,npm"
npx ssh-licco
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_SECURITY_LEVEL": "balanced",
"SSH_EXTRA_ALLOWED_COMMANDS": "git,pip,npm",
"SSH_BASE_DIR": "/home"
}
}
}
}
| 工具 | 描述 | 核心能力 |
|---|---|---|
ssh_connect | 连接管理 | 自动读取环境变量/配置,支持密码+密钥认证,可保存配置,登录后自动执行命令 |
ssh_execute | 命令执行 | 自动连接、智能后台检测、长任务等待、超时控制 |
ssh_disconnect | 会话管理 | 断开指定会话 OR 列出所有活跃会话 |
ssh_file_transfer | 文件传输 | 上传 / 下载 / 列目录 |
ssh_host | 主机管理 | action=list/add/remove 增删查主机配置 |
ssh_docker | Docker 管理 | action=ps/images/build/logs 全生命周期管理 |
ssh_generate_key | 密钥生成 | RSA / Ed25519 密钥对 |
用户:帮我查看服务器上的 Docker 容器
AI:调用 ssh_connect → ssh_execute "docker ps"
[执行结果]
CONTAINER ID IMAGE COMMAND STATUS PORTS
abc123 nginx "nginx" Up 2 days 80:80
用户:把这个文件上传到 /var/www/html
AI:调用 ssh_connect → ssh_file_transfer
[上传成功]
本地:./index.html
远程:/var/www/html/index.html
大小:2.3 KB
用户:帮我构建 Docker 镜像
AI:调用 ssh_execute(background=True) 后台执行 docker build...
[后台任务已启动]
Session ID: a1b2c3d4
命令:docker build -t myapp .
使用 ssh_execute(session_id="a1b2c3d4", command="cat /tmp/build.log") 查看进度
用户:检查 PostgreSQL 是否正常运行
AI:调用 ssh_execute "pg_isready -h localhost -p 5432"
[检查结果]
localhost:5432 - accepting connections
✅ PostgreSQL 运行正常
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_SECURITY_LEVEL": "balanced",
"SSH_EXTRA_ALLOWED_COMMANDS": "git,npm,docker,composer,pm2",
"SSH_BASE_DIR": "/var/www",
"SSH_HOST": "192.168.1.100",
"SSH_USER": "deploy",
"SSH_PASSWORD": "your-password"
}
}
}
}
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_SECURITY_LEVEL": "balanced",
"SSH_EXTRA_ALLOWED_COMMANDS": "pip,poetry,python3,pytest,black",
"SSH_HOST": "192.168.1.100",
"SSH_USER": "developer",
"SSH_PASSWORD": "your-password"
}
}
}
}
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_SECURITY_LEVEL": "balanced",
"SSH_EXTRA_ALLOWED_COMMANDS": "psql,mysql,mongosh,pg_isready",
"SSH_HOST": "192.168.1.100",
"SSH_USER": "dbadmin",
"SSH_PASSWORD": "your-password"
}
}
}
}
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_SECURITY_LEVEL": "relaxed",
"SSH_EXTRA_ALLOWED_COMMANDS": "sudo,apt,yum,systemctl,journalctl,docker,kubectl",
"SSH_HOST": "192.168.1.100",
"SSH_USER": "root",
"SSH_PASSWORD": "your-password"
}
}
}
}
{
"mcpServers": {
"ssh": {
"command": "ssh-licco",
"env": {
"SSH_SECURITY_LEVEL": "strict",
"SSH_HOST": "192.168.1.100",
"SSH_USER": "app-user",
"SSH_PASSWORD": "your-password",
"SSH_BASE_DIR": "/home/app-user"
}
}
}
}
以下依赖版本冲突已在测试环境中验证,不影响 ssh-licco 的正常使用:
fastapi 需要 starlette<0.51.0
但安装了 starlette 0.52.1
影响范围:
解决方案:
pip install starlette==0.50.0
pyopenssl 需要 cryptography<45
但安装了 cryptography 46.0.5
影响范围:
解决方案:
pip install cryptography==44.0.0
测试通过的配置:
测试场景:
ssh-licco 的核心依赖是:
mcp - MCP 协议实现asyncssh - SSH 客户端paramiko - SSH 客户端(稳定模式)pydantic - 数据验证而 starlette 和 cryptography 是通过 mcp 间接引入的。ssh-licco 本身不直接使用这些库的 API,因此版本冲突不会影响 ssh-licco 的功能。
Cannot find module 错误错误: Cannot find module '.../node_modules/ssh-licco/bin/ssh-licco.js'
原因: npm 全局目录存在损坏的 ssh-licco 包
解决:
npm uninstall -g ssh-licco
# 卸载后 npx 会重新从 npm registry 下载完整包
错误: Connection refused
解决:
systemctl status sshdufw status错误: Authentication failed
解决:
/var/log/auth.log错误: 命令 'xxx' 不在允许列表中
解决:
{
"SSH_SECURITY_LEVEL": "balanced",
"SSH_EXTRA_ALLOWED_COMMANDS": "被阻止的命令"
}
错误: pip install 后在 conda 环境中出现依赖冲突
解决:
npx ssh-licco 代替 pip install(完全隔离,不影响 conda 环境)conda create -n ssh-licco python=3.10 && conda activate ssh-licco && pip install ssh-liccopip install如果遇到 ModuleNotFoundError 之类的问题,ssh-licco 每次启动会自动验证依赖完整性并修复。你也可以手动运行:
node install.js
| 文档 | 描述 | 位置 |
|---|---|---|
| 📖 配置指南 | 完整配置选项和场景 | MCP_CONFIG_GUIDE.md |
| 🔐 安全指南 | 安全配置详解 | SECURITY_CONFIG_GUIDE.md |
| 📊 API 参考 | 完整 API 文档 | docs/API_REFERENCE.md |
| 🎓 Skills | 开发、运维、安装指南 | docs/skills/ |
| 📦 发布指南 | 版本发布流程 | docs/skills/RELEASE_SKILL.md |
ssh-licco 提供命令行接口,支持直接在终端执行 SSH 操作:
# 启动 MCP 服务器(默认模式)
ssh-licco
ssh-licco serve
# 查看版本
ssh-licco --version
ssh-licco exec --host 192.168.1.100 -u root --password pwd "ls -la /home"
ssh-licco exec --timeout 120 "docker ps"
# 上传文件
ssh-licco upload --host 192.168.1.100 -u root --password pwd ./local.txt /remote/path.txt
# 下载文件
ssh-licco download --host 192.168.1.100 -u root --password pwd /remote/log.txt ./local.log
ssh-licco list-hosts
ssh-licco list-hosts --json
💡 所有 CLI 子命令都支持环境变量配置(
SSH_HOST、SSH_USER、SSH_PASSWORD等),无需每次手动指定。
| 指标 | 状态 |
|---|---|
| 测试用例 | 402 passed, 3 skipped |
| 覆盖率 | 17 个源模块全覆盖 |
| 测试框架 | pytest + pytest-asyncio |
| 源模块 | 测试文件 | 用例数 |
|---|---|---|
exceptions.py | test_exceptions.py | 7 |
connection_config.py | test_connection_config.py | 8 |
security.py | test_security.py | 24 |
logging_config.py | test_logging_config.py | 8 |
audit_logger.py | test_audit_logger.py | 12 |
executor.py | test_executor.py | 8 |
watchdog.py | test_watchdog.py | 18 |
key_manager.py | test_key_manager.py | 6 |
config_manager.py | test_config_manager.py | 10 |
clients/interface.py | test_factory.py | 10 |
clients/paramiko_client.py | test_paramiko_client.py | 18 |
clients/factory.py | test_factory.py | 10 |
session_manager.py | test_session_manager.py | 18 |
connection_pool.py | test_connection_pool.py | 10 |
batch_executor.py | test_batch_executor.py | 10 |
cli.py | test_cli.py | 10 |
server.py | test_server.py | 30+ |
service.py | test_service.py | 14 |
# 运行全部测试
pytest tests/ -v
# 运行特定模块测试
pytest tests/test_security.py -v
# 查看覆盖率
pytest --cov=ssh_mcp --cov-report=term-missing
| 版本 | 日期 | 主要变更 |
|---|---|---|
| v1.2.1 | 2026-06-03 | 📝 README 文档更新,同步到 PyPI |
| v1.1.0 | 2026-06-01 | 🔥 精简重构!MCP 工具从 15 个合并为 7 个(ssh_connect/ssh_execute/ssh_disconnect/ssh_file_transfer/ssh_host/ssh_docker/ssh_generate_key),自动连接、智能后台检测、长任务等待 |
| v1.0.0 | 2026-05-31 | 🎉 首个主要版本!CLI 增强(exec/upload/download/docker-build/list-hosts)、完整测试套件(402 用例)、看门狗监控、审计日志、连接池、批量执行 |
| v0.5.5 | 2026-05 | 自动安装体系优化:依赖完整性检查、增量更新、Anaconda 检测、cli.py 精简 |
| v0.2.3 | 2026-03-14 | 修复 _logger 初始化 bug |
| v0.2.2 | 2026-03-14 | 安全配置增强(有 bug) |
| v0.2.1 | 2026-03-13 | 多级安全策略、环境变量配置 |
| v0.2.0 | 2026-03-12 | 安全验证模块、命令白名单 |
| v0.1.7 | 2026-03-11 | 基础功能、后台任务 |
欢迎贡献代码、文档和建议!
MIT License - 详见 LICENSE
ssh-licco)Made with ❤️ by Echoqili
Last updated: 2026-06-01
Be the first to review this server!
by Modelcontextprotocol · Developer Tools
Web content fetching and conversion for efficient LLM usage
by Toleno · Developer Tools
Toleno Network MCP Server — Manage your Toleno mining account with Claude AI using natural language.
by mcp-marketplace · Developer Tools
Create, build, and publish Python MCP servers to PyPI — conversationally.