SSH MCP Server
A Model Context Protocol server that allows LLMs to securely execute shell commands on remote Linux and Windows systems via SSH. It supports password and key-based authentication, command timeouts, and sudo elevation for administrative tasks.
README
SSH MCP Server
SSH MCP Server is a local Model Context Protocol (MCP) server that exposes SSH control for Linux and Windows systems, enabling LLMs and other MCP clients to execute shell commands securely via SSH.
Contents
Quick Start
- Install SSH MCP Server
- Configure SSH MCP Server
- Set up your MCP Client (e.g. Claude Desktop, Cursor, etc)
- Execute remote shell commands on your Linux or Windows server via natural language
Features
- MCP-compliant server exposing SSH capabilities
- Execute shell commands on remote Linux and Windows systems
- Secure authentication via password or SSH key
- Built with TypeScript and the official MCP SDK
- Configurable timeout protection with automatic process abortion
- Graceful timeout handling - attempts to kill hanging processes before closing connections
Tools
-
exec: Execute a shell command on the remote server- Parameters:
command(required): Shell command to execute on the remote SSH serverdescription(optional): Optional description of what this command will do (appended as a comment)
- Timeout Configuration:
- Parameters:
-
sudo-exec: Execute a shell command with sudo elevation- Parameters:
command(required): Shell command to execute as root using sudodescription(optional): Optional description of what this command will do (appended as a comment)
- Notes:
- Requires
--sudoPasswordto be set for password-protected sudo - Can be disabled by passing the
--disableSudoflag at startup if sudo access is not needed or not available - For persistent root access, consider using
--suPasswordinstead which establishes a root shell - Tool will not be available at all if server is started with
--disableSudo
- Requires
- Timeout Configuration:
- Timeout is configured via command line argument
--timeout(in milliseconds) - Default timeout: 60000ms (1 minute)
- When a command times out, the server automatically attempts to abort the running process before closing the connection
- Timeout is configured via command line argument
- Max Command Length Configuration:
- Max command characters are configured via
--maxChars - Default:
1000 - No-limit mode: set
--maxChars=noneor any<= 0value (e.g.--maxChars=0)
- Max command characters are configured via
- Parameters:
Installation
- Clone the repository:
git clone https://github.com/tufantunc/ssh-mcp.git cd ssh-mcp - Install dependencies:
npm install
Client Setup
You can configure your IDE or LLM like Cursor, Windsurf, Claude Desktop to use this MCP Server.
Required Parameters:
host: Hostname or IP of the Linux or Windows serveruser: SSH username
Optional Parameters:
port: SSH port (default: 22)password: SSH password (or usekeyfor key-based auth)key: Path to private SSH keysudoPassword: Password for sudo elevation (when executing commands with sudo)suPassword: Password for su elevation (when you need a persistent root shell)timeout: Command execution timeout in milliseconds (default: 60000ms = 1 minute)maxChars: Maximum allowed characters for thecommandinput (default: 1000). Usenoneor0to disable the limit.disableSudo: Flag to disable thesudo-exectool completely. Useful when sudo access is not needed or not available.
{
"mcpServers": {
"ssh-mcp": {
"command": "npx",
"args": [
"ssh-mcp",
"-y",
"--",
"--host=1.2.3.4",
"--port=22",
"--user=root",
"--password=pass",
"--key=path/to/key",
"--timeout=30000",
"--maxChars=none"
]
}
}
}
Claude Code
You can add this MCP server to Claude Code using the claude mcp add command. This is the recommended method for Claude Code.
Basic Installation:
claude mcp add --transport stdio ssh-mcp -- npx -y ssh-mcp -- --host=YOUR_HOST --user=YOUR_USER --password=YOUR_PASSWORD
Installation Examples:
With Password Authentication:
claude mcp add --transport stdio ssh-mcp -- npx -y ssh-mcp -- --host=192.168.1.100 --port=22 --user=admin --password=your_password
With SSH Key Authentication:
claude mcp add --transport stdio ssh-mcp -- npx -y ssh-mcp -- --host=example.com --user=root --key=/path/to/private/key
With Custom Timeout and No Character Limit:
claude mcp add --transport stdio ssh-mcp -- npx -y ssh-mcp -- --host=192.168.1.100 --user=admin --password=your_password --timeout=120000 --maxChars=none
With Sudo and Su Support:
claude mcp add --transport stdio ssh-mcp -- npx -y ssh-mcp -- --host=192.168.1.100 --user=admin --password=your_password --sudoPassword=sudo_pass --suPassword=root_pass
Installation Scopes:
You can specify the scope when adding the server:
-
Local scope (default): For personal use in the current project
claude mcp add --transport stdio ssh-mcp --scope local -- npx -y ssh-mcp -- --host=YOUR_HOST --user=YOUR_USER --password=YOUR_PASSWORD -
Project scope: Share with your team via
.mcp.jsonfileclaude mcp add --transport stdio ssh-mcp --scope project -- npx -y ssh-mcp -- --host=YOUR_HOST --user=YOUR_USER --password=YOUR_PASSWORD -
User scope: Available across all your projects
claude mcp add --transport stdio ssh-mcp --scope user -- npx -y ssh-mcp -- --host=YOUR_HOST --user=YOUR_USER --password=YOUR_PASSWORD
Verify Installation:
After adding the server, restart Claude Code and ask Cascade to execute a command:
"Can you run 'ls -la' on the remote server?"
For more information about MCP in Claude Code, see the official documentation.
Testing
You can use the MCP Inspector for visual debugging of this MCP Server.
npm run inspect
Disclaimer
SSH MCP Server is provided under the MIT License. Use at your own risk. This project is not affiliated with or endorsed by any SSH or MCP provider.
Contributing
We welcome contributions! Please see our Contributing Guidelines for more information.
Code of Conduct
This project follows a Code of Conduct to ensure a welcoming environment for everyone.
Support
If you find SSH MCP Server helpful, consider starring the repository or contributing! Pull requests and feedback are welcome.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。