Home > Linux, SSH > SSH Magic

SSH Magic

A friend of mine just recently posted a trick with long hostnames when using SSH. I have commented before many times when I see people making aliases or shorthand’s like this that they just don’t know about the magic that is possible in the SSH configuration file.

Take for example this, imagine having a long hostname, with an odd port and a different user. Typing that would be a pain, most people would do something like:

alias ssh-short="ssh -p 12345 someotheruser@somelong.hostname.com"

In their ~/.bashrc, however the same can be filled into the configuration file. Edit the file ~/.ssh/config (or make it!):

Host short
  HostName somelong.hostname.com
  User someotheruser
  Port 12345

After doing this you can simply do:

$ ssh short

How much easier do you need it to be?!

Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.