The optimization that compounds
ControlMaster reuses one TCP+SSH connection for many sessions to the same host. Without it, every ssh, scp, and rsync to a host opens a fresh connection — 200–500 ms of TCP handshake plus SSH negotiation each time. With it, the first connection becomes the master, and every subsequent connection rides that same channel — nearly instant.
This compounds dramatically for scripted operations. A loop that SSHs to the same host 20 times goes from "painfully slow" to "essentially free."
The three directives
ControlMaster auto— first connection becomes master; later ones reuse it.ControlPath ~/.ssh/sockets/%r@%h-%p— where to store the socket file.%r= remote user,%h= host,%p= port. Make sure the directory exists.ControlPersist 10m— keep the master alive for 10 minutes after the last session closes. Subsequentsshwithin that window is instant.
When something goes weird
Stale sockets are the only real failure mode. If a host gets stuck (network change, bug), you can either remove the socket file by hand or use ssh -O exit hostname to gracefully close the master.