Wednesday, March 24, 2010

How to make putty private key authenticated

Once in a while I need to access my ubuntu9.10 at home from my Windows laptop. This is pretty easy. Once I have a ssh client (putty) installed on my Windows, open a NAT for port 22 on my router, I can login my account by username and password.

This is very insecure as everyone know, a username/passwd authentication in clear text is easy for attackers too. So I changed the authentication to RSA public/private key authentication. Here is a link that gives a pretty good explanation about how to do that. https://help.ubuntu.com/community/SSH/OpenSSH/Keys. But it's talking about clients running linux.

In order for the windows client putty to work, these extra steps are needed:
1. On ubuntu (the ssh server), copy the newly generated public key id_rsa.pub to authorized_keys, and uncomment the "AuthorizedKeysFile %h/.ssh/authorized_keys" in sshd_config. Of course restart sshd by "/etc/init.d/ssh restart"

2. Copy the private key, id_rsa to windows, load it into puttygen and save it as private key in .ppk format. (You need to download puttygen.exe from putty website)

3. Change your session to use private key authentication, by loading the private key into your session's configuration. Don't forget to save your session's configuration!

And the next time you login, you will be asked for a passphrase for your private key. After that, you're logged in private key authenticated. And you feel secured!!!

No comments:

Post a Comment