Codumentor logo Codumentor

SSH Tunnel Plugin

The SSH Tunnel plugin opens and maintains a persistent SSH port-forward to a fixed remote server (localhost:<local_port><server_ip>:<remote_port>), with automatic reconnection if the tunnel drops. It is infrastructural: no agent tools, no UI.

Only one tunnel is managed per Codumentor server process.

Requirements

Configuration

plugins:
  - module: codumentor.plugins.ssh_tunnel
    class: SSHTunnelPlugin
    args:
      server_ip: "192.168.1.100"
      remote_port: 1248
      local_port: 1248
      enabled: true
ParameterTypeDefaultDescription
server_ipstring(required)IP address of the remote server
remote_portint1248Port on the remote server
local_portint1248Port to bind on localhost
ssh_key_pathstringNonePath to the SSH private key. If unset, auto-detects from the locations above
check_interval_secondsint30How often to check that the tunnel is still forwarding
ssh_userstring"root"Remote SSH username
enabledbooltrueDisable without removing the plugin from config

Behaviour

On startup the plugin checks whether local_port is listening and whether an HTTP GET to http://127.0.0.1:<local_port>/ actually forwards (any HTTP response counts). A healthy existing tunnel is adopted — including one started by another Codumentor instance on the same host. A listening port that does not forward is treated as a zombie: the stale process is killed and a new tunnel is created (ssh -f -N -L …).

A background loop repeats that check every check_interval_seconds and reconnects on failure. Tunnel failure is non-fatal: a warning is logged and the loop keeps retrying.

On shutdown, only a tunnel this process created is stopped. Adopted tunnels are left running so other Codumentor instances keep using them.

Security and ops notes