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.,
druidmatchesdruid.sysafe.co.uk). Prevents silent connection failures from case mismatches in tool configurations. Added July 2026 (commit82ced841). - Dial Cooldowns: Implements backoff logic to prevent aggressive retry loops if a server is temporarily unreachable.
- Thread Safety: Uses
sync.Mapto safely manage the connection pool across concurrent agent sessions.
Key Files
dpersistantssh/dpersistantssh.go: The core connection manager and command executor.
Integration Flow
- An agent invokes a remote tool (e.g.,
sasharunning adlan_server_statuscheck). - The tool calls
dpersistantssh.ExecuteRemoteCommand(). - The package checks the
sync.Mapfor an existing, open connection to that specific host. - If found, the command runs over the existing channel.
- 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.