Stop making SSH re-authenticate every damn time
SSH & Remote Administration
Stop making SSH re-authenticate every damn time
🧩 The Challenge
Ever hop onto a server, then need to scp a file, then maybe rsync something else, and each time it feels like SSH is starting from scratch? It’s slow, your key gets authenticated over and over, and frankly, it’s just annoying to wait for it.
💡 The Fix
You can tell SSH to reuse the first connection you make to a host. This makes subsequent connections lightning fast, avoids re-authentication prompts, and cuts down on TCP overhead. And it’s a massive quality-of-life improvement for busy admins.
# Add this to your ~/.ssh/config for a specific host, or globally for all hosts
Host some-server.example.com
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h:%p
ControlPersist 1h
# Then, connect as usual. The first connection creates the control socket.
ssh some-server.example.com
# Now, in another terminal, any new SSH, SCP, or rsync connection
# to 'some-server.example.com' will reuse that first session instantly.
scp local_file.txt some-server.example.com:/tmp/
ssh some-server.example.com "sudo systemctl status apache2"
⚙️ Why It Works
This works by having the first SSH session create a *control socket* on your local machine. Subsequent SSH commands for the same host detect this socket and reuse the existing TCP connection, essentially “piggybacking” on it without setting up a new session.
🚀 Pro-Tip: For super sensitive jumps, set `ControlPersist no`. But for hosts you’re constantly on, `ControlPersist 0` keeps that master channel open indefinitely, saving you even more time.
Linux Tips & Tricks | © ngelinux.com | 11/23/2026
