BS

blakerouse/ssh-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 4 forks 质量 56 趋势 0MIT

本地运行的SSH MCP服务器便于管理主机并在多台主机间执行命令

概览

SSH MCP 是运行在主机本地的 MCP 服务器,能够管理和交互远程 SSH 主机。它支持将主机组织成组,并同时在多个主机间执行命令。 - - 在SSH配置中添加一个新的Linux或Windows主机,并自动检测操作系统。连接字符串中的用户名和密码是可选的——如果未提供,当前用户和SSH代理将用于认证。- - 通过组和名称从SSH配置中移除主机。- - 从SSH配置中检索所有组列表。- - 从SSH配置中获取主机列表。可选地按组筛选。- - 获取Linux和Windows主机的缓存操作系统信息。你可以指定单个主机或整个组。- - 更新Linux和Windows主机的缓存操作系统信息。你可以指定单个主机或整个组。

概述(AI 翻译)

SSH MCP 是运行在主机本地的 MCP 服务器,能够管理和交互远程 SSH 主机。它支持将主机组织成组,并同时在多个主机间执行命令。

工具

主持人管理

  • add_host - 向SSH配置添加新的Linux或Windows主机,并实现自动操作系统检测。连接字符串中的用户名和密码为可选,若未提供,当前用户和SSH代理将用于认证。
  • remove_host - 通过组和名称从SSH配置中移除主机。
  • get_groups - 从SSH配置中获取所有组的列表。
  • get_hosts - 从SSH配置中检索主机列表。可选择按组筛选。
  • get_os_info - 获取Linux和Windows主机的缓存操作系统信息。你可以指定单个主机或整个组。
  • update_os_info - 更新Linux和Windows主机的缓存操作系统信息。你可以指定单个主机或整个组。

命令执行

  • perform_command - SSH进入远程机器并执行命令。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

SSH MCP

SSH MCP is an MCP server that runs locally on your host that provides the ability to manage and interact with remote SSH hosts. It supports organizing hosts into groups and executing commands across multiple hosts simultaneously.

Tools

Host Management

  • add_host - Adds a new Linux or Windows host to the SSH configuration with automatic OS detection. Username and password are optional in the connection string - if not provided, the current user and SSH agent will be used for authentication.
  • remove_host - Removes a host from the SSH configuration by group and name.
  • get_groups - Retrieves the list of all groups from the SSH configuration.
  • get_hosts - Retrieves the list of hosts from the SSH configuration. Can optionally filter by group.
  • get_os_info - Retrieves the cached operating system information for Linux and Windows hosts. You can specify individual hosts or an entire group.
  • update_os_info - Updates the cached operating system information for Linux and Windows hosts. You can specify individual hosts or an entire group.

Command Execution

  • perform_command - SSH into a remote machine and executes a command. You can specify individual hosts or an entire group. Commands that take longer than 30 seconds are automatically moved to background execution. Use background=true to run immediately in background.

Command Management

  • get_command_status - Retrieves the status and results of a background command by its command ID. If no ID is provided, returns the most recent command.
  • list_commands - Lists all background commands with their current status. Useful for tracking long-running commands.
  • cancel_command - Cancels a running background command by its command ID.

Features

  • Cross-platform support - Works with both Linux and Windows remote hosts with automatic OS detection
  • Group-based organization - Organize hosts into groups for easier management
  • Multiple authentication methods - Supports password, SSH agent, and SSH key files (~/.ssh/id_rsa, id_ed25519, etc.)
  • Secure host verification - Uses ~/.ssh/known_hosts for host key verification with automatic host addition
  • Concurrent execution - Execute commands across multiple hosts simultaneously
  • Automatic background execution - Commands that take longer than 30 seconds are automatically moved to background, with command IDs returned for status tracking
  • Persistent storage - Uses BadgerDB for efficient local storage

Limitations

  • SSH agent support is Unix-only (SSH_AUTH_SOCK) - password and key file authentication work on all platforms
  • Remote hosts can be Linux or Windows (automatic OS detection)

How to Setup

Checkout the repository:

$ git clone https://github.com/blakerouse/ssh-mcp

Build the binary:

$ go build .

Update the MCP configuration for Claude Desktop:

{
  "mcpServers": {
    "ssh": {
      "command": ""
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →