Setting up ssh key based authentication from a Windows machine

You have a windows machine simon(client) and abita(server) and you want to connect from simon to abita using ssh keys. We will be generating the keys from Windows machine. Key generation method using a linux mahcine is explained here.

Download the keygen software for Windows called puttygen.exe.
Launch puttygen.exe and click on Generate button. Follow the promts. Enter a passphrase for the key. Select and copy the public key generated and save it in a notepad temporarily. Now click on Save public key button and save the public on any location. Click on Save private key button and save the key some where safe for future use.



Now login to abita(server) machine using putty.exe. Use below command to edit authorized_keys file.

At a new line paste the public key copied in to the notepad earlier and save the file using ctrl+o.

Now try to login to the server using putty again, but this time using the private key we created. First prepare putty to use private key.
Laucnh putty and type in the ip address of your linux server in the Host Name field leave the Port as it is (assuming ssh port is not changed in your server). Type in a name for this session in Saved Sessions.
On the left pane click and Expand Connections->SSH->Auth After clicking on Auth on the right pane browse to the private key location where is it saved. Now on left pane click on Session and click on Save on the right pane.
Your newly creted connection will come in the list now. Just double click on the session and it will launch a new window (if it promt for a fingerprint warning click yes). After entering your user name you can see that it is promting for the key password (Authenticating with public key "rsa-key-20121205").





Now if you like to disable password based authentication completley (only when doing remote connections. Password authentication will still work from console) Edit /etc/ssh/sshd_config file and change PasswordAuthentication value to No.
Restart ssh service now.

Note: home directory permissions should be as below,

If you had given full permissions on your $home directory you may get "sever refused our key error"
To give correct permissions use below command,