Monday 2008.03.03At work, I'm constantly using ssh to connect to different servers. At home, I ssh into my iPhone (among other things), which means typing out an IP address each time I want to connect. Who wants to type out long server names or all those numbers every time? Not me.
I just figured out how to give ssh hosts "nicknames". If you put a file called config in the .ssh directory of your home folder (~/.ssh/config) then you can specify lots of different options for your ssh connections.
The options I'm interested in right now are Host and HostName. If you specify these, you can essentially give your ssh hosts nicknames. So, open up your favorite text editor and type the following:
Host nickname HostName somereallylongservername.com Host iphone HostName 192.168.1.69
PS - Make sure the file is in the ~/.ssh/ directory.
Ok, that's great. What does giving an ssh host a "nickname" do? It saves you time when you're typing out somereallylongservername.com or an IP address numerous times each day. Essentially, it turns this:
ssh user@somereallylongservername.com ssh somebody@192.168.1.69
Into this:
ssh you@nick ssh me@iphone
If you feel like it, you can set the User option to save yourself even more typing (ssh x). You can also specify the type of encryption to use, and all sorts of other things. Right now, I'm only interested in HostName, but you can find out about all the other options if you RTFM ;) Happy ssh'ing!