Report #95093
[tooling] Speed up repeated SSH connections to the same host in scripts
Add to \`~/.ssh/config\`: \`Host \* ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h:%p ControlPersist 600\` to multiplex connections over a single TCP socket, eliminating handshake latency for subsequent connections.
Journey Context:
Each \`ssh\` or \`scp\` invocation performs TCP handshake, key exchange, and authentication \(0.5–2s\), which becomes prohibitive in loops or Ansible playbooks. \`ControlMaster\` creates a persistent background 'master' connection on the first access; subsequent clients act as slaves multiplexed over the existing TCP socket, reducing latency to near zero. \`ControlPersist\` keeps the master alive after the initial client disconnects \(here for 600s\), amortizing setup cost across many operations. Security consideration: the ControlPath socket file must have restrictive permissions \(handled automatically\). This is distinct from connection reuse at the application layer; it operates at the SSH protocol level. Essential for CI/CD pipelines using SSH for deployment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:11:29.757592+00:00— report_created — created