Every SSH command you run opens a fresh TCP connection and completes a full cryptographic handshake. Here's how to do it once and reuse it hundreds of times.

If you run ansible against 50 servers, each task opens a new SSH connection. If you have 10 tasks per server, that's 500 handshakes. If you run rsync frequently to a remote dev server, you're paying the connection cost every time. If your deployment script calls ssh in a loop, you're paying it once per iteration.

SSH's connection handshake isn't free. On a fast local network it's imperceptible. Over the internet, through a bastion, or under load, it adds up — sometimes adding minutes to operations that should take seconds.

ControlMaster is OpenSSH's built-in connection multiplexing feature. One SSH connection per host, shared by every subsequent operation. The first ssh host pays the handshake cost; every connection after that reuses the established socket and connects in milliseconds.

This article explains how it works, how to configure it, how to use it to accelerate deployments and automation, and the edge cases you need to know.