Saturday, July 9, 2022

[SOLVED] Multiple SSH config files

Issue

I like the ability to specify hosts/identity files/etc in the ssh_config file. However, I would ideally like to have a couple different SSH configurations each under their own version control. Is there any way to reference another ssh_config type file from within ssh_config?

Something like this (the Load syntax is what I am looking for but can't find in the man pages.

~/.ssh/config

Load config_file_a
Load config_file_b     

~/.ssh/config_file_a

# Options for one host
Host serverA
    HostName serverA.myserver.com

~/.ssh/config_file_b

# Options for another host
Host serverB
    HostName serverB.myserver.com

Solution

No way to do that that I know of. If you really need to do this I'd suggest scripting it - i.e. write a script like so (assuming bash script, but you could use whatever your OS supports):

cat /path/to/config1 /path/to/config2 .... /path/to/configN > ~/.ssh/config

Rerun your script whenever you make a change to any one of your config files. Better yet, if your version control system supports script-hooks, automate it.



Answered By - ishaaq
Answer Checked By - Robin (WPSolving Admin)