Sunday, April 25, 2010

SSH Hostname Shortcut

As I work with 3 machines: laptop, desktop, and a server: all running 64-bit Linux, I often need to use ssh and scp. I find repeated typing of long hostnames stress inducing, with the chance of making a typo or just the pressure on my fingers. Here is a trick I use.

Create a file .ssh/config with the following entries:

Host [shortcut]
Hostname [full-hostname]
User [username]

where entries in [brackets] are to be filled with your entries. Additional entries like Port, ServerAliveInterval, etc. can also be filled out.

This along with public key based password-less ssh works like a charm. If you are as lazy (= productive) as I am, one-letter shortcuts for frequently used hosts like

$ ssh a

is enough.

No comments:

Post a Comment