The SSH config every Mac developer should steal
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
Switched after reading this and my battery life noticeably improved.
Try clearing the cache first, that fixed it for me.
Clear, short, and no fluff. More of this please.
Agreed, the Intel behaviour caught me out as well.
Saved this to my dotfiles notes. The tip at the end is gold.
Same here, it made a big difference.
Counterpoint: I have had the opposite experience on a Mac mini, but my workload is very different.
How does this compare with the approach in your earlier guide?
Finally someone explains this without assuming I already know it.
Nice pick. Already set it on both displays.
Printed this out and stuck it next to my desk. Old habits.
Agreed, the Intel behaviour caught me out as well.