dou7uw
Last Updated: February 25, 2016
·
15.44K
· gnrfan
A413c2580c75641ad7e79c4a2632d60d

Multiple aliases on every entry of SSH's config file

If you're not using SSH's config file located at $HOME/.ssh/config for easily accessing a remote host without remembering which was the port, the FQDN or IP address, the remote user account or the SSH key you're using with it please do yourself a favor and go set it.

Each entry looks like this:

host <alias>
    hostname <FQDN or IP address>
    user <remote user>
    port <remote port>
    IdentityFile <local path to private key file>

Well, it happened to me that my co-workers had agreed upon aliases for a few hosts but for me it was much easy to remember a customized alias more akin to the one I could have come up with me myself so I tried adding a second and a third and even more aliases to the same entry and as long as they are unique they all work!

So you can go something like this:

host server018 mongodb-box mongo
    hostname 192.168.3.1
    username devops
    port 2222
    IdentityFile ~/.ssh/id_dsa_devops

Then you can connect with "ssh server018", "ssh mongodb-box" or "ssh mongo" as it pleases you or you happen to remember first.

That's about it :)

Say Thanks
Respond

1 Response
Add your response

7524
70d9b050bfe39350c234d710fadfcd39

To easily setup your config for the Github SSH hosts, try my tool, github-keygen: https://github.com/dolmen/github-keygen

over 1 year ago ·
Filed Under