KK

kinothe-kafkaesque/ssh-mcp-server

开发工具

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

11 stars 5 forks 质量 74 趋势 28MIT

this is a collection of tools that allows your agent to execute commands on your remote servers

概览

A Model Context Protocol (MCP) server implementation that provides SSH capabilities. This server allows for secure remote access and execution through the MCP protocol. - SSH server implementation using MCP protocol - SQLite database integration for data persistence - TypeScript implementation for type safety and better development experience - Node.js 18 or higher - npm or yarn package manager - TypeScript knowledge for development To install SSH Server for Claude Desktop automatically via Smithery: The server uses a SQLite database (ssh.db) to store SSH credentials. The database file will be created automatically when the server starts. The server stores named credentials, then every remote action refers to a credentialName. privateKeyPath must point to an existing private key. - add_credential: save { "name", "host", "username", "privateKeyPath" }. - list_credentials: list stored credential records. - remove_credential: delete { "name" }.

README

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

SSH MCP Server

A Model Context Protocol (MCP) server implementation that provides SSH capabilities. This server allows for secure remote access and execution through the MCP protocol.

Features

  • SSH server implementation using MCP protocol
  • SQLite database integration for data persistence
  • TypeScript implementation for type safety and better development experience

Prerequisites

  • Node.js 18 or higher
  • npm or yarn package manager
  • TypeScript knowledge for development

Installation

Installing via Smithery

To install SSH Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @KinoThe-Kafkaesque/ssh-mcp-server --client claude

Manual Installation

  1. Clone the repository:
git clone 
cd ssh-server
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

Usage

Configuration

The server uses a SQLite database (ssh.db) to store SSH credentials. The database file will be created automatically when the server starts.

Tools

The server stores named credentials, then every remote action refers to a credentialName. privateKeyPath must point to an existing private key (~/ expands to your home directory).

Host keys are verified: the first time a credential connects, the server’s host key fingerprint is pinned in ~/ssh.db. Later connections that present a different key are refused with HOST_KEY_MISMATCH. To pin a known key up front, pass hostKeyFingerprint (the SHA256:... value printed by ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the server). After a legitimate key change, remove the credential and add it again.

  • add_credential: save { "name", "host", "username", "privateKeyPath", "hostKeyFingerprint"? }.
  • list_credentials: list stored credential records.
  • remove_credential: delete { "name" }.
  • ssh_exec: run a shell command with { "credentialName", "command", "timeout" }.
  • ssh_exec_raw: run an argv-style command array, for example { "credentialName": "prod", "command": ["grep", "-E", "foo|bar", "/var/log/app.log"] }.
  • scp_copy: copy one file over SFTP with { "credentialName", "localPath", "remotePath", "direction" }.
  • rsync_copy: copy directories or larger trees with rsync and the same transfer shape.
  • ssh_session_start, ssh_session_send, ssh_session_read, ssh_session_end, ssh_session_list: manage interactive SSH sessions.
  • ssh_tunnel_start, ssh_tunnel_list, ssh_tunnel_stop: manage local or remote port-forwarding tunnels.

Example:

{
  "tool_name": "ssh_exec",
  "arguments": {
    "credentialName": "prod",
    "command": "uptime",
    "timeout": 120000
  }
}

Starting the server

npm start
在 GitHub 查看完整 README

安装

npx -y @smithery/cli install @KinoThe-Kafkaesque/ssh-mcp-server --client claude
新手?先看 mcpskill.org 教程 →