mcp-ssh

mcp-ssh

Enables SSH remote command execution, passwordless key management, Windows Session 0 desktop process launching, and SFTP file transfers across Windows, Linux, and macOS.

Category
访问服务器

README

sshctl

A unified CLI and Model Context Protocol (MCP) server for cross-platform SSH remote execution, passwordless key management, Windows Session 0 interactive desktop process launching, and SFTP file transfers.


Architecture

Terminal / Human (CLI)             AI Agent (Claude / Antigravity)
       │                                         │
       ▼                                         ▼
  sshctl (bin/sshctl.js)               MCP Protocol (stdio JSON-RPC)
       │                                         │
       └──────────────────┬──────────────────────┘
                          ▼
                   Core SSH Engine
                          │
          ┌───────────────┼───────────────┐
          ▼               ▼               ▼
   Connection Pool    PowerShell/UTF-16LE   SFTP Channel
   (60s idle reuse)   (Session 0 / 8K limit) (FastPut / FastGet)
          │               │               │
          └───────────────┼───────────────┘
                          ▼
                  Remote Target Host
            (Windows / Linux / macOS)

Features

  • Dual-Mode: Run interactively via CLI (sshctl) or as an automated MCP server (sshctl mcp).
  • Zero Local Client Shell Dependencies: Pure TypeScript with ssh2. Does not require WSL, Git Bash, sshpass, iconv, or local ssh binaries.
  • Automated PowerShell Command Encoding: Converts Windows command bodies to Base64 UTF-16LE strings (powershell.exe -EncodedCommand), removing quote escaping errors.
  • Session 0 Desktop Handoff (--desktop): Launches Windows GUI applications directly onto the logged-in user's interactive desktop (Session 1) via Task Scheduler.
  • 8,191-Character Auto-Fallback: Automatically detects when PowerShell payloads exceed the cmd.exe command length limit, uploading a temporary script via SFTP with execution and cleanup.
  • Connection Pooling: Reuses SSH2 connections per user@host:port with 60-second idle timeouts.
  • Profiles & Secret Resolution: Store targets in ~/.sshctl/profiles.json, resolving environment variables (env:VAR_NAME) without storing plain text passwords in chat logs.

Quick Start

1. Build

cd claude/sshctl
npm install
npm run build
npm test        # 43 unit and integration tests

2. CLI Usage

# List profiles
sshctl profiles

# Test connectivity and probe remote OS
sshctl test my-profile

# Run remote command
sshctl exec my-profile "hostname && dir"

# Launch GUI app on Windows active desktop
sshctl exec my-profile "calc.exe" --desktop

# Upload/Download files via SFTP
sshctl push my-profile local.txt /remote/path/file.txt
sshctl pull my-profile /remote/path/file.txt local.txt

# Generate Windows OpenSSH installer 1-liner
sshctl bootstrap-rdp --admin

3. Register as MCP Server

sshctl implements the standard Model Context Protocol (MCP). Any MCP client automatically discovers all tools, arguments, and prompts over stdio JSON-RPC without needing external configuration files.

Claude Code CLI

claude mcp add sshctl -- node "/path/to/sshctl/dist/index.js"

Claude Desktop (claude_desktop_config.json) / Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "sshctl": {
      "command": "node",
      "args": ["/path/to/sshctl/dist/index.js"]
    }
  }
}

Google Antigravity

To enable Antigravity's lazy-loading schema discovery:

npm run export:schemas

This automatically writes tool definition JSONs and instructions.md to ~/.gemini/antigravity/mcp/sshctl/.


MCP Tools Reference

  • ssh_list_profiles: List profiles from ~/.sshctl/profiles.json.
  • ssh_test_connection: Probe SSH connectivity & detect target OS.
  • ssh_clear_known_hosts: Clear stale entries from ~/.ssh/known_hosts.
  • ssh_exec: Execute remote commands with Base64 UTF-16LE, Session 0 bypass (desktop: true), and output capping.
  • ssh_setup_passwordless: Deploy ed25519 key to Linux (~/.ssh/authorized_keys) or Windows (administrators_authorized_keys with strict ACLs).
  • ssh_remove_passwordless: Revoke public key or clear all keys.
  • ssh_upload_file: Upload file via SFTP.
  • ssh_download_file: Download file via SFTP.
  • ssh_generate_rdp_bootstrap: Generate OpenSSH installation 1-liner.

Technical Documentation

For details on PowerShell Base64 encoding, the 8,191-character boundary fallback, Session 0 bypass mechanism, and error code tables, see docs/REFERENCE.md.


License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选