Ancient Programming

What I encounter in my software part of life is in danger of being commented upon here

Howto setup smooth ssh access

Posted by Jacob von Eyben on October 24th, 2008

Everytime I have a new machine or a new ssh access to setup I forgot how to configure the access so I don’t have to type the username each time (if I login with a different user).
At the same time I would like to use a private rsa key. So here goes a note to myself and other scatter brains :-)

Instead of always have to type username and password like this:

[jeyben@machine ~]$ ssh username@www.ancientprogramming.com
Password:
Last login: Fri Oct 24 16:31:03 2008 from somewhere
[username@servername ~]$

I would like to just do the following:

[jeyben@machine ~]$ ssh ancientprogramming
Last login: Fri Oct 24 16:31:03 2008 from somewhere
[username@servername ~]$

Create and use a public/private key pair

Client

$ ssh-keygen -t rsa
$ scp ~/.ssh/id_rsa.pub www.ancientprogramming.com:~

Server

$ cat ~/id_rsa.pub >> .ssh/authorized_keys

Modify .ssh/config

Host ancientprogramming
  User <username>
  Port 22
  HostName www.ancientprogramming.com
  LocalForward 3307 localhost:3306 (setup a localforward for the default mysql port)

One Response to “Howto setup smooth ssh access”

  1. Jason Kilgrow Says:

    something that I do because I don’t want to have to fiddle with username/password at work but is more secure out of the office, is to copy my authorized_keys to a flash drive. then I create a symlink in my .ssh directory from the authorized_keys on the flash drive to my .ssh directory on my laptop.

    ln -s /media/mystuff/authorized_keys .ssh/authorized_keys

    so, when I have my flash drive plugged in/mounted, ssh uses the public/private key signon. if it can’t find that file (the flash drive isn’t mounted), it falls back on username/password for the authentication. very nice for laptops that live both in the workplace and at home.

    if it’s okay, i’m going to post the link to this blog entry on my blog: developmentech.wordpress.com

    Thanks!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>