OpenSSH version 7.3 introduced a very handy Include feature, which is great for people who have to manage connection info for multiple servers. This makes it easy for me to generate updated SSH configs via AWS CLI for the multiple EC2 instances that serve Adafruit IO.

Here is how you can use Include to pull in separate SSH config files from your main ~/.ssh/config. First, you will need to install OpenSSH version 7.3 or higher. If you are using Linux, you will need to install version 7.3+ via your package manager (yum,apt-get, etc), or build it from source.

On OS X, you can do this via homebrew:

$ brew install homebrew/dupes/openssh

Confirm that you are now running 7.3 or higher by running ssh -V:

$ ssh -V
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016

Now you can create a new child config file in ~/.ssh using a text editor. For example, we can create an example child config at ~/.ssh/pi_config and add configuration info just as we would in the main SSH config file:

Host pi-1
  HostName 10.0.0.10
  User pi
  IdentityFile ~/.ssh/pi_cluster

Host pi-2
  HostName 10.0.0.11
  User pi
  IdentityFile ~/.ssh/pi_cluster

Host pi-3
  HostName 10.0.0.12
  User pi
  IdentityFile ~/.ssh/pi_cluster

From your main ~/.ssh/config, add the following line at the top:

Include ~/.ssh/pi_config

You should now be able to connect to your servers as you normally would:

$ ssh pi-1

That’s it! Check out this OpenSSH feature request if you would like more info about the new feature.