I have enjoyed using an SSH client from the command line for many years. One particularly useful feature is that you can make it even more convenient with a .ssh/config file. I like to put tunnel configurations, key assignments, usernames, ports, proxy commands, and other things in this file. You can quickly look up exactly what can be configured in the man page.
man ssh_config
Since I manage all my systems (both customer systems and my own) in the SSH config file, it has grown quite quickly over the years and become somewhat confusing. Unfortunately, there is no supported "Include" directive. Old servers I no longer needed soon accumulated in the file. So I looked for a simple solution for managing it. I would like to briefly introduce this very simple setup here.
The basic idea is to split the configuration into individual files. Each file is named after the customer whose systems I am creating entries for. I then put these files in a subdirectory, ~/.ssh/conf.d.
Example:
.ssh ├── conf.d │ ├── __default.conf │ ├── customer1.conf │ ├── customer2.conf │ ├── customer3.conf │ └── private.conf ├── config ├── id_rsa └── id_rsa.pub
In my case, there are 44 files in total. Quite a lot, then. Now all that remains is to generate the ~/.ssh/config file.
I wrote a small script to generate the file:
#!/bin/sh rm ~/.ssh/config # cat with an empty line after each file awk 'FNR==1{print ""}{print}' conf.d/\*.conf > ~/.ssh/config
In the end, you get a nicely sorted SSH configuration file.