Skip to main content
Glama
caly1337

Dark Stack SSH MCP Server

by caly1337
README.md
# Dark Stack - SSH MCP Server

A Model Context Protocol (MCP) server for remote access to **dark.lmphq.net** (ASUS AI machine) using SSH with passwordless authentication. This is an SSH-based alternative to the plink-based dgx-stack solution.

## Features

- Execute commands on remote servers via SSH
- List Docker containers on remote hosts
- Read files from remote systems
- Secure authentication via password or SSH keys
- Based on the MCP protocol for LLM integration

## Installation

```bash
npm install
```

## Configuration

1. Copy `.env.template` to `.env`:
```bash
cp .env.template .env
```

2. Configure your SSH connection in `.env`:

### Option 1: Password Authentication
```env
SSH_HOST=your-server.com
SSH_PORT=22
SSH_USERNAME=your-username
SSH_PASSWORD=your-password
```

### Option 2: SSH Key Authentication (Recommended)
```env
SSH_HOST=your-server.com
SSH_PORT=22
SSH_USERNAME=your-username
SSH_PRIVATE_KEY=/path/to/your/private/key
# SSH_PASSPHRASE=your-key-passphrase  # if key is encrypted
```

## MCP Configuration

Add to your `.mcp.json`:

```json
{
  "mcpServers": {
    "ssh-remote": {
      "command": "node",
      "args": ["F:\\AI-PROD\\projects\\dark.lmphq.net\\index.js"],
      "env": {
        "SSH_HOST": "your-server.com",
        "SSH_PORT": "22",
        "SSH_USERNAME": "your-username",
        "SSH_PASSWORD": "your-password"
      },
      "type": "stdio"
    }
  }
}
```

Or use environment variables from .env file.

## Available Tools

### docker_ps
Lists running Docker containers on the remote host.

**Usage:**
```javascript
{
  "name": "docker_ps"
}
```

### exec_command
Executes a shell command on the remote host.

**Parameters:**
- `command` (string, required): The command to execute

**Usage:**
```javascript
{
  "name": "exec_command",
  "arguments": {
    "command": "hostname"
  }
}
```

### read_file
Reads a file from the remote host using SFTP.

**Parameters:**
- `path` (string, required): The absolute path to the file

**Usage:**
```javascript
{
  "name": "read_file",
  "arguments": {
    "path": "/etc/hostname"
  }
}
```

## Security Considerations

1. **Use SSH keys instead of passwords** when possible
2. **Never commit** your `.env` file with credentials
3. **Restrict SSH access** using firewall rules and SSH config
4. **Use strong passwords/passphrases** if required
5. **Consider using SSH agent** for key management

## Differences from plink-based solution

| Feature | plink | SSH (this implementation) |
|---------|-------|---------------------------|
| Platform | Windows | Cross-platform |
| Authentication | Password in command | Env vars or key files |
| Security | Passwords visible in process list | Environment-based config |
| SSH Keys | Requires PuTTY format | Standard OpenSSH format |
| Configuration | Hardcoded in commands | Centralized .env file |

## Testing

```bash
# Test the server directly
npm start
```

## Troubleshooting

### Connection timeout
Increase `SSH_TIMEOUT` in your `.env` file.

### Authentication failed
- Verify your username and password/key
- Check SSH server logs on the remote host
- Ensure SSH server allows password/key authentication

### Permission denied
- Verify file paths are absolute
- Check file permissions on remote host
- Ensure user has necessary permissions

## License

MIT