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)
October 25th, 2008 at 4:29 pm
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!