Last Updated: May 15, 2019
·
38.57K
· gnrfan

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 :)

1 Response
Add your response

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 ·