Last night I discovered the Include directive in ~/.ssh/config that I have wanted all my life.

I’m using it as follows…

In ~/.ssh/config:

Include config.d/*

Then various sub-files, like ~/.ssh/config.d/10-home for my home network:

Host *.local
  AddressFamily inet
  User priddle

And ~/.ssh/config.d/20-work for work:

Host *
  User jpriddle
  Port 1234

And ~/.ssh/config.d/99-star for everything else:

Host *
  TCPKeepAlive yes
  ServerAliveInterval 300
  ServerAliveCountMax 6
  AddKeysToAgent yes
  IgnoreUnknown UseKeychain
  UseKeychain yes
  ForwardAgent no
  IdentityFile ~/.ssh/id_rsa

Why? So I can keep some of this configuration on GitHub while keeping some stuff private.