Codumentor logo Codumentor

Remote SSH Plugin

Experimental — This plugin is under active development. APIs and behavior may change in future releases.

The Remote SSH Plugin registers ssh_exec, ssh_upload, and ssh_download tools that allow the agent to run commands and transfer files on remote hosts via SSH/SFTP.

Overview

The Remote SSH plugin:

  1. Registers three tools: ssh_exec (execute shell commands), ssh_upload (SFTP upload), ssh_download (SFTP download)
  2. Maintains a per-session connection pool with configurable idle timeout and keepalive
  3. Uses Trust On First Use (TOFU) host key verification, stored in an OpenSSH-format known hosts file
  4. Supports pre-configured named host aliases and ad-hoc connections to arbitrary hosts

Requirements

The Python package asyncssh must be installed:

pip install asyncssh

Configuration

Basic Configuration

plugins:
  - module: codumentor.plugins.remote_ssh
    class: RemoteSSHPlugin
    args:
      enabled: true
      allow_adhoc: true         # Allow connecting to hosts not in 'hosts' map (default: true)
      default_timeout: 30       # Command timeout in seconds (default: 30)
      max_output_size: 10240    # Max output bytes per tool call (default: 10240)

Pre-Configured Hosts

Define named hosts to avoid specifying connection details on each call:

plugins:
  - module: codumentor.plugins.remote_ssh
    class: RemoteSSHPlugin
    args:
      hosts:
        prod-server:
          hostname: 192.168.1.10
          port: 22
          username: deploy
          key_filename: ~/.ssh/id_rsa
        dev-server:
          hostname: dev.example.com
          username: developer

Full Configuration

plugins:
  - module: codumentor.plugins.remote_ssh
    class: RemoteSSHPlugin
    args:
      enabled: true
      target_agents: "main"
      allow_adhoc: true
      default_timeout: 30
      max_output_size: 10240
      keepalive_interval: 30          # SSH keepalive in seconds (default: 30)
      idle_timeout: 60                # Close idle connections after N seconds (default: 60)
      max_connections_per_session: 5  # Max pooled connections per session (default: 5)
      known_hosts_path: ./data/ssh_known_hosts  # TOFU host key store path
      hosts:
        my-server:
          hostname: 10.0.0.5
          username: ubuntu

Configuration Parameters

ParameterTypeDefaultDescription
enabledbooltrueEnable/disable the plugin
target_agentsstring"main"Which agents get the tools ("main", "subagent", "all")
allow_adhocbooltrueAllow connections to hosts not in the hosts map
default_timeoutint30Default command execution timeout (seconds)
max_output_sizeint10240Maximum output size per tool call (bytes)
keepalive_intervalint30SSH keepalive interval (seconds)
idle_timeoutint60Close idle connections after N seconds of inactivity
max_connections_per_sessionint5Maximum pooled connections per conversation session
known_hosts_pathstring./data/ssh_known_hostsPath to the TOFU known hosts file (OpenSSH format)

Tools

ssh_exec

Execute a shell command on a remote host.

ParameterRequiredDescription
hostYesHostname/IP or pre-configured alias
commandYesShell command to run
usernameNoSSH username (overrides config)
timeoutNoCommand timeout in seconds

ssh_upload

Upload a local file to a remote host via SFTP.

ParameterRequiredDescription
hostYesHostname/IP or pre-configured alias
local_pathYesSource file path on the Codumentor server
remote_pathYesDestination path on the remote host
usernameNoSSH username

ssh_download

Download a file from a remote host via SFTP.

ParameterRequiredDescription
hostYesHostname/IP or pre-configured alias
remote_pathYesSource path on the remote host
local_pathYesDestination path on the Codumentor server
usernameNoSSH username

Host Key Verification (TOFU)

On the first connection to a new host, the plugin records the host's public key in known_hosts_path (OpenSSH format). Subsequent connections verify against the stored key, providing protection against MITM attacks after initial trust is established.

User Settings

Users can override two settings via the Web UI (Settings → Remote SSH):

Notes