Shaike1_mcp Server Ssh

Shaike1_mcp Server Ssh

🚀 MCP SSH服务器

MCP SSH服务器是一款功能强大的服务器,它基于SSH协议实现,专为模型上下文协议(MCP)量身设计。该服务器借助SSH协议,支持安全的远程命令执行与文件操作,同时提供密码和基于密钥的身份验证方式。

🚀 快速开始

MCP SSH服务器能通过SSH协议实现安全的远程命令执行和文件操作,支持多种身份验证方式,为用户提供便捷、安全的使用体验。

✨ 主要特性

  • ✨ 安全的SSH连接管理
  • 🔑 密码和基于密钥的身份验证
  • 💻 远程命令执行
  • 📁 文件操作(上传/下载)
  • 📊 传输进度跟踪
  • 🔐 权限管理
  • 📂 目录操作
  • 🚀 批量文件传输
  • 📝 详细日志记录

📦 安装指南

安装包

npm install mcp-ssh

添加到您的Claude桌面配置(claude_desktop_config.json

{
"mcpServers": {
"ssh": {
"command": "node",
"args": ["%APPDATA%/npm/node_modules/mcp-ssh/dist/server.js"],
"env": {
"SSH_PORT": "8889",
"SSH_LOG_LEVEL": "info"
}
}
}
}

💻 使用示例

基础用法

密码身份验证

$body = @{
id = "test"
host = "example.com"
port = 22
username = "user"
password = "pass123"
} | ConvertTo-Json

Invoke-RestMethod -Uri "http://localhost:8889/connect" -Method Post -Body $body -ContentType "application/json"

密钥身份验证

$body = @{
id = "test"
host = "example.com"
port = 22
username = "user"
privateKey = Get-Content ~/.ssh/id_rsa | Out-String
passphrase = "optional-key-passphrase"  # 如果您的密钥受密码保护
} | ConvertTo-Json

Invoke-RestMethod -Uri "http://localhost:8889/connect" -Method Post -Body $body -ContentType "application/json"

执行命令

$execBody = @{
id = "test"
command = "ls -la"
} | ConvertTo-Json

Invoke-RestMethod -Uri "http://localhost:8889/exec" -Method Post -Body $execBody -ContentType "application/json"

文件操作

# 上传文件
$uploadForm = @{
file = Get-Item -Path "localfile.txt"
remotePath = "/remote/path/file.txt"
}
Invoke-RestMethod -Uri "http://localhost:8889/upload/test" -Method Post -Form $uploadForm

# 下载文件
Invoke-RestMethod -Uri "http://localhost:8889/download/test?remotePath=/remote/path/file.txt" -Method Get -OutFile "downloaded.txt"

目录操作

# 列出目录
Invoke-RestMethod -Uri "http://localhost:8889/ls/test?path=/remote/path" -Method Get

# 获取连接状态
Invoke-RestMethod -Uri "http://localhost:8889/status/test" -Method Get

📚 详细文档

开发步骤

克隆仓库

git clone https://github.com/shaike1/mcp-server-ssh.git
cd mcp-server-ssh

安装依赖项

npm install

构建

npm run build

启动服务器

npm start

环境变量

属性 详情
服务器端口 SSH_PORT,默认值为8889
日志级别 SSH_LOG_LEVEL,默认值为info

贡献指南

  1. 叉克隆仓库
  2. 创建功能分支(git checkout -b feature/amazing-feature
  3. 提交更改(git add .git commit -m "您的提交消息"
  4. 推送到远程仓库(git push origin feature/amazing-feature
  5. 提交拉取请求

问题反馈

如果您遇到任何问题或有改进建议,请在GitHub仓库中创建问题。


感谢使用MCP SSH服务器!

  • 0 关注
  • 0 收藏,12 浏览
  • system 提出于 2025-09-30 16:12

相似服务问题