by classfang
ssh-mcp-server is an SSH-based MCP (Model Context Protocol) server that allows remote execution of SSH commands via the MCP protocol, enabling AI assistants and other applications to safely operate remote servers.
ssh-mcp-server is a bridging tool that enables AI assistants and other applications supporting the MCP protocol to execute remote SSH commands through a standardized interface. This allows AI assistants to safely operate remote servers, execute commands, and retrieve results without directly exposing SSH credentials to AI models.
ssh-mcp-server can be run directly using NPX without global installation. You can configure it using command-line options for host, port, username, password, private key, and passphrase. It supports password authentication, private key authentication, and private key with passphrase. You can also define command whitelists and blacklists using regular expressions to control executable commands. Multiple SSH connections can be configured and managed by name.
Using Password:
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--password pwd123456"
]
}
}
}
Using Private Key:
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--privateKey ~/.ssh/id_rsa"
]
}
}
}
Using Command Whitelist:
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--password pwd123456",
"--whitelist ^ls( .*)?,^cat .*,^df.*"
]
}
}
}
npx @fangjunjie/ssh-mcp-server \
--ssh "name=dev,host=1.2.3.4,port=22,user=alice,password=xxx" \
--ssh "name=prod,host=5.6.7.8,port=22,user=bob,password=yyy"
Q: How does ssh-mcp-server ensure security? A: It supports secure SSH connection methods, uses command whitelists/blacklists for control, and isolates SSH credentials locally, never exposing them to AI models.
Q: Can I transfer files using ssh-mcp-server? A: Yes, it supports bidirectional file transfers, allowing you to upload files to servers or download files from servers.
Q: How can I restrict the commands that can be executed?
A: You can use the --whitelist
and --blacklist
parameters with regular expressions to define allowed and disallowed commands.
Q: Can I manage multiple SSH connections?
A: Yes, you can specify multiple SSH connections by passing multiple --ssh
parameters, each with a unique name, and then specify the connectionName
in your MCP tool calls.
SSH-based MCP (Model Context Protocol) server that allows remote execution of SSH commands via the MCP protocol.
English Document | δΈζζζ‘£
ssh-mcp-server is a bridging tool that enables AI assistants and other applications supporting the MCP protocol to execute remote SSH commands through a standardized interface. This allows AI assistants to safely operate remote servers, execute commands, and retrieve results without directly exposing SSH credentials to AI models.
GitHub: https://github.com/classfang/ssh-mcp-server
NPM: https://www.npmjs.com/package/@fangjunjie/ssh-mcp-server
Tool | Name | Description |
---|---|---|
execute-command | Command Execution Tool | Execute SSH commands on remote servers and get results |
upload | File Upload Tool | Upload local files to specified locations on remote servers |
download | File Download Tool | Download files from remote servers to local specified locations |
list-servers | List Servers Tool | List all available SSH server configurations |
Options:
-h, --host SSH server host address
-p, --port SSH server port
-u, --username SSH username
-w, --password SSH password
-k, --privateKey SSH private key file path
-P, --passphrase Private key passphrase (if any)
-W, --whitelist Command whitelist, comma-separated regular expressions
-B, --blacklist Command blacklist, comma-separated regular expressions
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--password pwd123456"
]
}
}
}
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--privateKey ~/.ssh/id_rsa"
]
}
}
}
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--privateKey ~/.ssh/id_rsa",
"--passphrase pwd123456"
]
}
}
}
Use the --whitelist
and --blacklist
parameters to restrict the range of executable commands. Multiple patterns are separated by commas. Each pattern is a regular expression used to match commands.
Example: Using Command Whitelist
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--password pwd123456",
"--whitelist ^ls( .*)?,^cat .*,^df.*"
]
}
}
}
Example: Using Command Blacklist
{
"mcpServers": {
"ssh-mpc-server": {
"command": "npx",
"args": [
"-y",
"@fangjunjie/ssh-mcp-server",
"--host 192.168.1.1",
"--port 22",
"--username root",
"--password pwd123456",
"--blacklist ^rm .*,^shutdown.*,^reboot.*"
]
}
}
}
Note: If both whitelist and blacklist are specified, the system will first check whether the command is in the whitelist, and then check whether it is in the blacklist. The command must pass both checks to be executed.
You can specify multiple SSH connections by passing multiple --ssh parameters, each with a unique name:
npx @fangjunjie/ssh-mcp-server \
--ssh "name=dev,host=1.2.3.4,port=22,user=alice,password=xxx" \
--ssh "name=prod,host=5.6.7.8,port=22,user=bob,password=yyy"
In MCP tool calls, specify the connection name via the connectionName
parameter. If omitted, the default connection is used.
Example (execute command on 'prod' connection):
{
"tool": "execute-command",
"params": {
"cmdString": "ls -al",
"connectionName": "prod"
}
}
You can use the MCP tool list-servers
to get all available SSH server configurations:
Example call:
{
"tool": "list-servers",
"params": {}
}
Example response:
[
{ "name": "dev", "host": "1.2.3.4", "port": 22, "username": "alice" },
{ "name": "prod", "host": "5.6.7.8", "port": 22, "username": "bob" }
]
Please log in to share your review and rating for this MCP.