Report #86483
[tooling] Slow repeated SSH connections to same host in scripts or rsync operations
Add to \`~/.ssh/config\`: \`Host \* ControlMaster auto ControlPath ~/.ssh/controlmasters/%r@%h:%p ControlPersist 10m\` to reuse TCP connections across multiple SSH/SCP/rsync invocations, reducing per-connection latency from seconds to milliseconds.
Journey Context:
AI agents and CI scripts often run sequences like \`ssh host cmd1\`, \`ssh host cmd2\`, \`rsync ...\`, \`git pull/push\` over SSH. Each invocation performs full TCP handshake, SSH protocol negotiation, key exchange, and authentication \(especially slow with password-protected keys or 2FA\). OpenSSH's ControlMaster feature creates a Unix socket at ControlPath that multiplexes subsequent connections over the initial authenticated connection. \`ControlMaster auto\` creates the master if absent, else slaves to it. \`ControlPersist 10m\` keeps the master open in background for 10 minutes after the last client disconnects. This reduces per-command overhead to essentially zero. The tradeoff is that if the master connection dies \(network blip\), all multiplexed sessions die immediately. Also, the socket file must have restrictive permissions \(700 on the directory\). This is distinct from ProxyJump \(which routes through bastions\) - this is for connection reuse to the final target. For scripts, ensure \`~/.ssh/controlmasters/\` exists with \`mkdir -p\` first.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:45:09.256482+00:00— report_created — created