Signal9Signal9 — home
online
back to labs

SSH Power Config: Connection Multiplexing & Keepalives

MediumLinux Fundamentals20-30 min
The brief

You already know a ~/.ssh/config Host alias. Now make SSH fast and resilient with two power-user defaults every heavy SSH user sets once and forgets.

1. Connection multiplexing — the first SSH connection opens a master; every later connection to the same host rides the SAME TCP/auth session over a control socket, so the second ssh/scp/git push is instant (no new handshake). You enable it with ControlMaster auto and a ControlPath socket, usually with ControlPersist so the master lingers.

2. Keepalives — ServerAliveInterval makes the client ping idle connections so they don't get silently dropped by NAT/firewalls.

Edit ~/.ssh/config so these apply to your hosts (a Host * block is the idiomatic place for defaults). Grading resolves your config with ssh -G labbox — the command that prints SSH's effective settings for a host — so the directives have to actually take effect, not just be present as text.

Required effective settings for labbox:

  • ControlMaster = auto
  • ControlPath = a real socket path (not none)
  • ServerAliveInterval = a positive number (e.g. 30)
What you'll do
  • Add a Host * defaults block (or a labbox block) to ~/.ssh/config
  • Enable multiplexing: ControlMaster auto + a ControlPath socket (ControlPersist recommended)
  • Set ServerAliveInterval to a positive number of seconds
  • Verify with: ssh -G labbox | grep -iE 'controlmaster|controlpath|serveraliveinterval'

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.