Last Updated: February 25, 2016
·
990
· pauld

Full hostnames with ssh config

I frequently use my laptop from home, where I have to get into my work network via VPN.

Because of some particulars of our VPN setup, the general domain of my computer isn't set up over VPN as it would be when I'm physically at work. Meaning, if at work I could connect to the dev server with a simple ssh dev, from home I need to do a full hostname, ssh dev.myworkserver.com. Even when on the VPN.

Fortunately, ssh's config file can save my poor brain a little context-switching by knowing the full hostname for any shortname I might need:

Host dev
HostName dev.myworkserver.com

Now I can ssh dev both places, and not be concerned with remembering the full name depending on where I am.

Bonus:

You can combine this with the "User" property if you routinely need to use a username other than your default.

Host dev
User pablo

Would log me into the dev server as the username pablo instead. Pretty nifty!

1 Response
Add your response

For advanced SSH aliases to connect to Github, check github-keygen : https://github.com/dolmen/github-keygen/

over 1 year ago ·