Reputation: 11142
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
Upvotes: 7
Views: 6839
Reputation: 28172
Since OpenSSH v7.3 in 2016, you can use Include
as per man ssh_config
:
Include
Include the specified configuration file(s). Multiple
pathnames may be specified and each pathname may contain
glob(7) wildcards and, for user configurations, shell-like
‘~’ references to user home directories. Wildcards will be
expanded and processed in lexical order. Files without
absolute paths are assumed to be in ~/.ssh if included in a
user configuration file or /etc/ssh if included from the
system configuration file. Include directive may appear
inside a Match or Host block to perform conditional
inclusion.
Upvotes: 10
Reputation: 6769
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.
Upvotes: 0