New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

ssh-agent-mcp-server

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-agent-mcp-server

MCP server for SSH remote server management with SSH agent authentication support

npmnpm
Version
0.1.0
Version published
Weekly downloads
126
63.64%
Maintainers
1
Weekly downloads
 
Created
Source

SSH MCP Server

An MCP (Model Context Protocol) server for SSH remote server management with SSH agent authentication support.

This server solves a common problem with SSH MCP servers: support for passphrase-protected SSH keys. By using SSH agent authentication, you can securely connect to remote servers without exposing your key passphrase.

Highlights

  • SSH Agent Authentication - Seamlessly works with passphrase-protected SSH keys via SSH agent
  • Private Key File Support - Alternative authentication via direct private key file
  • Command Execution - Run shell commands on remote servers
  • File Transfer - Upload and download files via SFTP
  • Directory Listing - Browse remote file systems
  • Tool Groups - Control which tools are available (readonly, write, admin)

Authentication Priority

The server supports multiple authentication methods and will use them in this order:

  • SSH Agent (recommended) - If SSH_AUTH_SOCK is set or auto-detected
  • Private Key File - If SSH_PRIVATE_KEY_PATH is set

Both methods can be configured simultaneously. If SSH agent authentication is available, it takes priority. The private key file method is used as a fallback or when the agent is not available.

Capabilities

Tools

ToolGroupDescription
ssh_connection_inforeadonly, write, adminGet configured SSH connection information
ssh_list_directoryreadonly, write, adminList directory contents on remote server
ssh_downloadreadonly, write, adminDownload file from remote server via SFTP
ssh_uploadwrite, adminUpload file to remote server via SFTP
ssh_executeadminExecute shell command on remote server

Resources

ResourceDescription
ssh://configSSH connection configuration and status (for debugging)

Tool Groups

Control which tools are available via the ENABLED_TOOLGROUPS environment variable:

GroupDescription
readonlySafe operations (connection info, list, download)
writeFile modifications (upload)
adminFull access including command execution

Examples:

  • ENABLED_TOOLGROUPS="readonly" - Only allow browsing and downloads
  • ENABLED_TOOLGROUPS="readonly,write" - Allow file transfers but no command execution
  • Not set - All tools enabled (default)

Quick Start

Installation

npx ssh-agent-mcp-server

Or install globally:

npm install -g ssh-agent-mcp-server

Configuration

Environment Variables

VariableRequiredDescriptionDefault
SSH_HOSTYesHostname or IP address of the SSH server-
SSH_USERNAMEYesUsername for SSH authentication-
SSH_PORTNoSSH port number22
SSH_AUTH_SOCKNoPath to SSH agent socketAuto-detected
SSH_PRIVATE_KEY_PATHNoPath to private key file-
SSH_PASSPHRASENoPassphrase for encrypted private key-
SSH_TIMEOUTNoConnection timeout in milliseconds30000
ENABLED_TOOLGROUPSNoComma-separated tool groupsAll enabled

Claude Desktop Configuration

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "ssh": {
      "command": "npx",
      "args": ["-y", "ssh-agent-mcp-server"],
      "env": {
        "SSH_HOST": "192.168.1.100",
        "SSH_USERNAME": "deploy",
        "SSH_AUTH_SOCK": "${SSH_AUTH_SOCK}"
      }
    }
  }
}

Restart Claude Desktop and you should be ready to go!

SSH agent authentication is the recommended method for passphrase-protected keys:

  • Ensure your SSH agent is running with your key loaded:

    # Check if agent is running
    ssh-add -l
    
    # If not, add your key
    ssh-add ~/.ssh/id_ed25519
    
  • Pass the SSH_AUTH_SOCK environment variable to the MCP server

The server will automatically use the agent for authentication, and your passphrase-protected key stays secure in the agent.

How It Works

  • Your passphrase-protected key is loaded into the SSH agent via ssh-add
  • The agent exposes a Unix socket at $SSH_AUTH_SOCK
  • This MCP server connects to that socket via the ssh2 library
  • The agent signs authentication challenges using your decrypted key
  • Your private key never leaves the agent - the MCP server never sees it

This is more secure than:

  • Storing your passphrase in environment variables
  • Using unprotected private keys
  • Manually entering passphrases

Tool Details

ssh_execute

Execute a command on the remote server.

Parameters:

  • command (required): Shell command to execute
  • cwd (optional): Working directory
  • timeout (optional): Command timeout in ms

Example:

{
  "command": "ls -la /var/log",
  "cwd": "/home/user"
}

Returns: JSON with stdout, stderr, and exit code

ssh_upload

Upload a file to the remote server via SFTP.

Parameters:

  • localPath (required): Absolute path to local file
  • remotePath (required): Destination path on server

ssh_download

Download a file from the remote server via SFTP.

Parameters:

  • remotePath (required): Path on remote server
  • localPath (required): Local destination path

ssh_list_directory

List directory contents on the remote server.

Parameters:

  • path (required): Directory path to list

Returns: JSON array with filename, type, size, permissions, modified time

ssh_connection_info

Get information about the configured SSH connection.

Returns: JSON with host, port, username, and authentication details

Development

# Install dependencies
npm run install-all

# Build
npm run build

# Run in development mode
npm run dev

# Run tests
npm test
npm run test:integration

License

MIT

Keywords

mcp

FAQs

Package last updated on 08 Jan 2026

Related posts