1. home
  2. guides
  3. the-ssh-config-every-mac-developer-should-steal

The SSH config every Mac developer should steal

Diego Alvarez Guides 1 min read 12 comments 53 views

Most people type long ssh commands they could have written once in ~/.ssh/config. A few lines give you short host names, faster reconnects, and keys that unlock with Touch ID.

Use the Keychain

UseKeychain yes and AddKeysToAgent yes store your passphrase in the macOS Keychain, so you type it once per login rather than once per connection.

Share connections

ControlMaster auto with a ControlPersist timeout reuses one TCP connection for every session to the same host. Git over SSH becomes noticeably faster.

One key per host

IdentitiesOnly yes stops the agent offering every key to every server, which avoids "too many authentication failures" errors.

  • Keep private keys in a password manager agent if you can.
  • Use Include to split work and personal hosts.
  • Never commit your config if it names internal hosts.
~/.ssh/config
Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentitiesOnly yes
  ControlMaster auto
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlPersist 10m

Any sufficiently advanced technology is indistinguishable from magic.

Arthur C. Clarke, Profiles of the Future (1973 revision)

Run ssh -G hostname to print the final configuration ssh will use for a host.

$ cat /comments 12

K
Kenji Mori Sep 16, 2026 · 9:31 AM

Switched after reading this and my battery life noticeably improved.

P
Pablo Ortiz Sep 18, 2026 · 1:57 AM

Try clearing the cache first, that fixed it for me.

L
Lucy Tran Sep 16, 2026 · 3:50 PM

Clear, short, and no fluff. More of this please.

K
Kenji Mori Sep 18, 2026 · 7:43 PM

Agreed, the Intel behaviour caught me out as well.

E
Elif Kaya Sep 16, 2026 · 11:44 PM

Saved this to my dotfiles notes. The tip at the end is gold.

J
Jonas Becker Sep 17, 2026 · 10:29 AM

Same here, it made a big difference.

S
Sofia Lind Sep 17, 2026 · 3:21 AM

Counterpoint: I have had the opposite experience on a Mac mini, but my workload is very different.

S
Sofia Lind Sep 18, 2026 · 7:34 AM

How does this compare with the approach in your earlier guide?

S
Sofia Lind Sep 19, 2026 · 8:50 AM

Finally someone explains this without assuming I already know it.

C
Chidi Eze Sep 19, 2026 · 3:19 PM

Nice pick. Already set it on both displays.

M
Marco Bellini Sep 20, 2026 · 11:30 AM

Printed this out and stuck it next to my desk. Old habits.

O
Owen Hughes Sep 20, 2026 · 5:23 PM

Agreed, the Intel behaviour caught me out as well.

$ echo "leave a comment"