SSH连接管理服务器

用于管理Cisco网络设备SSH连接的服务器,提供连接、配置和监控功能。

  • by aroshak
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 aroshak/cisco-ssh-mcp

使用说明

思科SSH MCP服务器

用于管理与思科网络设备的SSH连接的模型上下文协议(MCP)服务器。此服务器提供用于通过SSH连接、配置和监视Cisco路由器和交换机的工具。

特性

  • 多个SSH连接:同时管理与多个Cisco设备的连接
  • 命令执行:在连接的设备上执行任何CLI命令
  • 配置管理:进入配置模式并应用配置更改
  • 显示命令:使用可选的输出解析执行show命令
  • 原始终端访问:发送交互式会话的原始文本
  • 连接管理:列出、连接和断开与设备的连接
  • 安全认证:支持基于密码和密钥的身份验证

安装

npm install
npm run build

用法

作为MCP服务器

配置您的MCP客户端(如Cline)以使用此服务器:

{
  "mcpServers": {
    "cisco-ssh": {
      "command": "node",
      "args": ["path/to/cisco-ssh-mcp/dist/index.js"]
    }
  }
}

命令行用法

# Start the MCP server
npm start

# Start with default connection parameters
cisco-ssh-mcp --host 192.168.1.1 --username admin

可用工具

ciscoconnect

通过SSH连接到Cisco设备。

参数:

  • host (必填):IP地址或主机名
  • username (必填):SSH用户名
  • password:SSH密码
  • privateKey:用于身份验证的私钥
  • port:SSH端口(默认值:22)
  • connectionId:连接的唯一标识符

ciscoexec

在连接的设备上执行命令。

参数:

  • command (必填):执行命令
  • connectionId:使用哪种连接
  • timeout:命令超时(毫秒)

cisco_config

进入配置模式并执行配置命令。

参数:

  • commands (必填):配置命令数组
  • connectionId:使用哪种连接
  • save:更改后是否保存配置

cisco_show

使用可选的输出解析执行show命令。

参数:

  • command (必需):显示要执行的命令
  • connectionId:使用哪种连接
  • parseOutput:将输出解析为结构化格式

cisco_send_raw

将原始文本发送到SSH连接。

参数:

  • text (必填):要发送的原始文本
  • connectionId:使用哪种连接
  • waitForPrompt:等待命令提示符

cisco_list_连接

列出所有活动的SSH连接。

cisco_断开连接

断开与设备的连接。

参数:

  • connectionId:要断开的连接

例子

连接到设备

// Connect using password
{
  "tool": "cisco_connect",
  "arguments": {
    "host": "192.168.1.1",
    "username": "admin",
    "password": "cisco123",
    "connectionId": "router1"
  }
}

// Connect using SSH key
{
  "tool": "cisco_connect",
  "arguments": {
    "host": "192.168.1.1",
    "username": "admin",
    "privateKey": "-----BEGIN RSA PRIVATE KEY-----\\n...",
    "connectionId": "router1"
  }
}

执行命令

// Show interface status
{
  "tool": "cisco_show",
  "arguments": {
    "command": "show ip interface brief",
    "parseOutput": true
  }
}

// Configure an interface
{
  "tool": "cisco_config",
  "arguments": {
    "commands": [
      "interface GigabitEthernet0/1",
      "ip address 192.168.10.1 255.255.255.0",
      "no shutdown"
    ],
    "save": true
  }
}

安全考虑

  • 尽可能使用SSH密钥而不是密码
  • 为管理流量实施适当的网络分段
  • 为所有执行的命令启用日志记录
  • 使用专用管理VLAN
  • 实施适当的访问控制和身份验证

故障排除

  • 连接超时:检查设备上的网络连接和SSH服务
  • 认证失败:验证凭据和SSH配置
  • 命令超时:增加慢速设备的超时值
  • 权限不足:确保用户具有适当的权限

许可证

MIT许可证-有关详细信息,请参阅许可证文件。