Codumentor logo Codumentor Enterprise

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
health_check_timeout_secondsfloat10Timeout of one HTTP probe through the tunnel
zombie_failure_thresholdint3Consecutive failed probes (one per check interval) before a listening-but-not-forwarding tunnel is restarted

Behaviour

ssh runs as a direct child of the Codumentor process (ssh -N -L … -o ExitOnForwardFailure=yes, no -f), so the plugin knows exactly which process it started. It only ever stops that process — never by name or pattern, never a tunnel some other process holds.

On startup, if local_port is already listening, the plugin uses it as-is: whoever holds it (another Codumentor instance on the same host, a host-level tunnel) keeps owning it. Otherwise it starts its own tunnel. When several instances share one forward port, only one can bind it; the others use that tunnel, and if it dies they race to recreate it — the losers' ssh exits on the bind failure and they use the winner's.

A background loop runs every check_interval_seconds:

Tunnel failure is non-fatal: a warning is logged and the loop keeps retrying.

On shutdown, only a tunnel this process created is stopped.

Security and ops notes