Reuse your SSH connections for blazing speed
SSH & Remote Administration
Reuse your SSH connections for blazing speed
🧩 The Challenge
Ever jump between a bunch of servers, and every single SSH connection feels like it takes forever to set up? You type your alias, hit Enter, and then wait… wait for the handshake, the key exchange, authentication, sometimes even MFA prompts. It’s a drag, especially when you’re just dropping in to grep a log file or check a service status on multiple boxes. Drives me absolutely bonkers.
💡 The Fix
There’s a simple SSH config trick that’ll make all subsequent connections to the *same host* almost instant. It reuses the first connection you make, so you only pay that initial overhead once. Saves a ton of time throughout the day when you’re jumping around.
# Add this to your ~/.ssh/config file:
Host *
ControlMaster auto
ControlPath ~/.ssh/cm_sockets/%r@%h:%p
ControlPersist 5m
# You'll also need to create the directory for the sockets if it doesn't exist:
mkdir -p ~/.ssh/cm_sockets
⚙️ Why It Works
This tells SSH to try and reuse an existing connection (ControlMaster auto). If one isn’t found, it establishes a new connection and makes it the ‘master.’ All subsequent connections for that host then use the socket specified by ControlPath to piggyback on the master. ControlPersist keeps that master connection open in the background for a set time, even after you disconnect your last client.
🚀 Pro-Tip: Set ControlPersist to ‘no’ or a very short duration if you’re connecting from untrusted systems or shared jump boxes. Don’t want lingering connections hanging around.
Linux Tips & Tricks | © ngelinux.com | 11/3/2026
