Overview

Last updated: July 24, 2026

Persistent SSH Module Overview (dpersistantssh)

The dpersistantssh package manages high-performance, long-lived SSH connections for remote execution tools used by the assistant.

Key Features

  • Connection Pooling: Caches active SSH connections to prevent the overhead of re-authenticating for every command.
  • Credential Management: Safely stores and maps hardcoded or configured credentials for specific external servers (e.g., sysafe, london-hosting).
  • Case-Insensitive Registry Lookup: Host matching is case-insensitive with short-name aliases (e.g., druid matches druid.sysafe.co.uk). Prevents silent connection failures from case mismatches in tool configurations. Added July 2026 (commit 82ced841).
  • Dial Cooldowns: Implements backoff logic to prevent aggressive retry loops if a server is temporarily unreachable.
  • Thread Safety: Uses sync.Map to safely manage the connection pool across concurrent agent sessions.

Key Files

  • dpersistantssh/dpersistantssh.go: The core connection manager and command executor.

Integration Flow

  1. An agent invokes a remote tool (e.g., sasha running a dlan_server_status check).
  2. The tool calls dpersistantssh.ExecuteRemoteCommand().
  3. The package checks the sync.Map for an existing, open connection to that specific host.
  4. If found, the command runs over the existing channel.
  5. If not, a new SSH client is dialed, authenticated, added to the pool, and then the command is run.

Guidance for AI Agents

  • Performance: Remote execution tools backed by this package are very fast after the initial connection. Do not hesitate to run multiple small diagnostic commands sequentially.
  • Isolation: Be aware that your SSH session state (like exported variables or directory changes) does not persist between individual command executions, even if the underlying SSH connection does.

Cross-References