3 ms·
Show HN: Make ssh config more manageable
For those who are not familiar with the .ssh/config file, this is a nice way of making aliases when ssh-ing into a server.
So instead of constantly typing:
ssh root@mywebserveroverthere.somesubdomian.somedomain.com
you can create an alias for it in a file called config in the .ssh directory like this:
Host web1
HostName mywebserveroverthere.somesubdomian.somedomain.com
User root
IdentityFile ~/.ssh/id_rsa
From now on you can just type:
ssh web1
and you're in!
However, over time my config file has gotten longer and longer, and is becoming harder to manage. It would be nice if I could split into individual files.
Unfortunately the config file has no way of including other files, so ... Make to the rescue.
1. split your config files into meaningful files starting with config_ e.g.
config_webservers
config_dbs
2. create a file called Makefile in the .ssh directory and add the following:
config: FORCE
cat config_* > config
FORCE:
3. Save the file
note: the second line must begin with a tab or it wont work. 'FORCE' is a way to force the creation of a new file every time.
Now you can update the individual files and when done, you can run
Make config
and it will produce a new config file for you.
I'd appreciate your comments, or if you have a better way of doing this.