Organize SSH config with Includes

My SSH config file has grown organically over the years. Overall, I try to keep it organized and well-commented. Today I thought to ask if I could include other files in my config, to separate groups of related servers into separate files. The answer, delightfully, is yes!

You can include specific files, or even an entire directory. I went with the latter:

Include config.d/*

Adding this line to the top of ~/.ssh/config means that I can create as many files as I want in ~/.ssh/config.d/, and any Host stanzas in those files will be included as if they are in ~/.ssh/config.

Now I have a separate file for each customer who’s servers I access: ~/.ssh/config.d/customer1, ~/.ssh/config.d/customer2, etc. Any time I add a new customer’s servers, I can add a new file and it’s automatically included. This makes it easier both to see which servers are associated with a customer and to see which customers’ servers I may have access to (for when I need to clean up later).