Mastodon
sungate.co.uk

sungate.co.uk

Ramblings about stuff

SSH goodness

Sometimes you discover stuff that things you’ve used for years can be made easier to use. Like Open SSH
for example.

When connecting to remote hosts, with different usernames and sometimes different ports, you often need to use long-winded command-line options:

ssh username@somehost
ssh otherusername@someotherhost
ssh -p 1234 yetanotherusername@yetanotherhost

However, you can edit your ~/.ssh/config to provide shortcuts for all this:

Host alias1
  Hostname somehost
  User username
Host alias2
  Hostname someotherhost
  User otherusername
Host alias3
  Hostname yetanotherhost
  User yetanotherusername
  Port 1234

This allows you to simply do:

ssh alias1
ssh alias2
ssh alias3

This also works for scp and sftp, intelligently picking up the appropriate details. You can always over-ride the defaults if you really need to, of course.

I Can’t Believe I Never Knew That Before(TM) 🙂

7 Responses to SSH goodness

  1. OhhhhhhhhhhhhHHH! Sweeeeeeeeeeeet!

    Permalink
  2. I picked that up from the guy who has all his home directory etc in Subversion, namely :

    http://www.onlamp.com/pub/a/onlamp/2005/01/06/svn_homedir.html

    I’ve been too lazy to use it, and instead just stick alias’es in my ~/.bashrc.

    e.g. alias home=”ssh david@home”
    alias work=”ssh dg@work -CAY”

    etc

    Permalink
  3. Wow that is really useful. Saved me a lot of hassle 😀

    Permalink
  4. Wow. Cool. I always learn something new from you!

    Permalink
  5. That’s really useful – thanks for posting it!

    Permalink
  6. Maybe I should do a whole series of “Davee’s Tips and Tricks” … 🙂

    Permalink
  7. […] came across this thanks to Davee when he posted SSH Goodness two years ago. Showing my ~/.ssh/config to a friend the other day, he asked me to post a more […]

    Permalink

Comments are closed.