Skip to main content
Glama
README.md
# remote-ssh-mcp

MCP server for **persistent SSH sessions** with native GUI credential prompts.

[![npm version](https://badge.fury.io/js/remote-ssh-mcp.svg)](https://www.npmjs.com/package/remote-ssh-mcp)

## Features

- 🔗 **Persistent Sessions** - Connections survive across multiple commands
- 🔐 **GUI Credential Prompts** - Native dialogs on Linux/macOS/Windows
- 📁 **File Transfer** - Upload/download via SFTP
- ⏱️ **Background Commands** - Run long tasks without blocking
- 🔄 **Session Reuse** - Automatic connection pooling per host
- 🛡️ **Secure** - Per-process secrets, localhost-only helper

## Installation

```bash
npm install -g remote-ssh-mcp
```

## Quick Start

Add to your MCP client config:

```json
{
  "mcpServers": {
    "ssh": {
      "command": "remote-ssh-mcp"
    }
  }
}
```

That's it! Connect to servers and credentials will be prompted via native GUI.

## Configuration

### Environment Variables (Optional)

Skip GUI prompts by setting credentials:

```json
{
  "mcpServers": {
    "ssh": {
      "command": "remote-ssh-mcp",
      "env": {
        "SSH_USER": "deploy",
        "SSH_PASSWORD": "secret"
      }
    }
  }
}
```

### Host Config File (Optional)

Create `~/.ssh/mcp-hosts.json`:

```json
{
  "defaults": { "username": "admin" },
  "hosts": {
    "prod.example.com": {
      "username": "deploy",
      "keyPath": "~/.ssh/deploy_key"
    }
  }
}
```

## Tools

| Tool | Description |
|------|-------------|
| `ssh_connect` | Connect to SSH server, returns session_id |
| `ssh_exec` | Execute command (with optional background mode) |
| `ssh_read_buffer` | Read terminal output history |
| `ssh_disconnect` | Close a session |
| `list_sessions` | List active sessions |
| `scp_upload` | Upload file via SFTP |
| `scp_download` | Download file via SFTP |

## Example Usage

```
1. ssh_connect(host="server.com", auth_mode="password")
   → { session_id: "abc-123", status: "connected" }

2. ssh_exec(session_id="abc-123", command="cd /app && git pull")
   → { stdout: "Already up to date.", exit_code: 0 }

3. ssh_exec(session_id="abc-123", command="npm run build", background=true)
   → { status: "running", pid: "12345" }

4. ssh_read_buffer(session_id="abc-123", lines=50)
   → { lines: ["Building...", "Done!"], total_buffered: 150 }
```

## GUI Requirements

For credential prompts:
- **Linux**: `zenity` (`apt install zenity`)
- **macOS**: Built-in (osascript)
- **Windows**: Built-in (PowerShell)

Without GUI, use environment variables or config file.

## Security

- Credentials prompted via native OS dialogs
- Never logged or written to disk
- Per-process authentication tokens
- Localhost-only credential helper
- Sessions auto-expire after 15 min inactivity

## License

MIT

TDQS

A3.5/5.0

Scored across 7 tools

Disambiguation5/5

Each tool has a clearly distinct purpose with no ambiguity: list_sessions manages session enumeration, ssh_connect/disconnect handle connection lifecycle, ssh_exec runs commands, ssh_read_buffer retrieves output, and scp_download/upload handle file transfers. The descriptions clearly differentiate between session management, command execution, and file operations.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern with clear prefixes: ssh_ for session/command operations, scp_ for file transfers, and list_ for enumeration. The naming is perfectly predictable and follows a logical convention throughout the set.

Tool Count5/5

With 7 tools, this server is well-scoped for remote SSH operations. Each tool earns its place by covering essential functions: connection management, command execution, output reading, file transfer, and session listing. The count is neither too sparse nor bloated for the domain.

Completeness4/5

The toolset provides excellent coverage for core SSH workflows: connect, execute, read output, transfer files, and manage sessions. A minor gap exists in advanced session features like interactive shell handling or terminal resizing, but agents can work around this with ssh_exec. The surface supports most common remote operations without dead ends.