/dev/nikc/blog

Kuolleiden purjehduskenkien seura

Feb 21st 2015

Host aliases and tab completion for SSH

13:02

Despite being a relentless tinkerer, for some bizarre reason instead of using the proper mechanics I’ve resorted to aliases for hosts I log in to frequently. Thankfully, the mental strain of remembering all the hosts I log in to finally forced me to sit down for 2 minutes and add the host + username combinations into my ssh-config. (Procrastination is such a beautiful word!)

<code>Host freq
HostName some.long.hostname.that.i.need.frequently.com
User mysysadminassignedmethis</code>

Configuration blocks like the example above shorten the full command to ssh freq from ssh mysysadminassignedmethis@some.long.hostname.that.i.need.frequently.com. Quite an improvement, I’m sure you’ll agree.

However, since I did a proper job, naming things in a logical and consistent manner using patterns such as servicename-stg for the staging environment and servicename-prod for the corresponding live host, there was still quite a lot of typing to do. If you saw my post about tab completion for project folders you can probably guess where this is going.

As I now have all the relevant information in ~/.ssh/config it’s very easy to parse out a helpful wordlist to create ssh tab completion. I have it and now you can have it, too.

Download ssh-complete.bash, source it from your ~/.bashrc and simply TAB away.

There are plenty of other useful things you can set in your ssh-config. See its man page for further information.

Sorry, the comment form is closed at this time.

Meta

Pages

Search blog

Latest comments