We have a bastion server that we use to connect to multiple hosts, and our .ssh/config has grown to over a thousand lines (we have hundreds of hosts that we connect to). This is beginning to get a little unwieldy and I'd like to know if there is a way to break the .ssh/config file up into multiple files. Ideally, we'd specify somewhere that other files would be treated as an .ssh/config file, possibly like:
~/.ssh/config
~/.ssh/config_1
~/.ssh/config_2
~/.ssh/config_3
...
I have read the documentation on ssh/config, and I don't see that this is possible. But maybe someone else has had a similar issue and has found a solution.
Best Answer
The
~/.ssh/config
file don't have a directive for including other files, possibly related to SSH's check for file permissions.Suggestions around this can include a script to cat several changes together either on the system or via checkin hooks on a repository. One might also look into tools such as Puppet or Augeas.
However you approach it, though, you'll have to concatenate individual files to be a single file from outside of the file.
note: overwrite:
>
v.s. append:>>
Update December 2017:
From 7.3p1 and up, there is the Include option. Which allows you to include configuration files.