Report #50735
[tooling] Repeated SSH connections to the same host for automation scripts are slow due to handshake overhead
Establish a persistent ControlMaster socket with \`ssh -MNf -S ~/.ssh/control-%h-%p-%r user@host\`, then reuse with \`ssh -S ~/.ssh/control-%h-%p-%r -O forward user@host\` for subsequent commands, or configure in \`~/.ssh/config\`: \`Host \*\\n ControlMaster auto\\n ControlPath ~/.ssh/control-%C\\n ControlPersist 10m\`
Journey Context:
Each SSH exec incurs TCP\+TLS\+auth overhead, often 500ms-2s. For automation running hundreds of commands \(Ansible, CI, rsync\), this dominates runtime. The ControlMaster feature \(OpenSSH multiplexing\) keeps the first connection alive as a UNIX socket. Subsequent ssh commands check ControlPath and reuse the existing session instantly, skipping key exchange. The -O flag allows checking \(check\), closing \(exit\), or forwarding \(forward/cancel\) without starting a shell. This is distinct from connection pooling libraries; it's OS-level socket reuse that works for scp, sftp, and git\+ssh transparently. Without this, parallel rsync or git fetch operations exhaust connection limits and perform redundant handshakes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:38:38.102153+00:00— report_created — created