Archives

Tag: ssh key

I have been trying all day to set up SSH keys on a linux server and Windows 7 client, finally with succes.

The way I managed to finally do it is like this:

Log into your linux server

Type:

ssh-keygen -t dsa

Accept default filename

Provide a strong passphrase

The keygen will create two files: id_dsa.pub, and id_dsa. The first one is the public key (.pub), the second one it the private key, copy this to your Windows 7 client.

While stil on your server, now put the contents of id_dsa.pub into ~/.ssh/authorized_keys

Make sure you

chmod 600 ~/.ssh/authorized_keys

Now move to your Windows 7 client and run puttygen.exe

Load the id_dsa you have copied from the server

Enter the passphrase

Now use the save private key button to save the private key in putty .pkk format

Now open putty and go to: Connection » SSH » Auth and browse for the .pkk to use as private key

Now click open and you should be able to login into your server without the text: Server refused our key

If you followed the above and it still shows the text: Server refused our key, just read on…

Bonus steps that might solve your problem:

In your server console issue the command: hostname

Your hostname will be shown now, write it down or remember it

Now start putty and in the Host Name (or IP address) input field enter that hostname (I am assuming you have allready set up a working hostname)

With the .ppk selected as in step 11 press Open and you will be able to login without the text: Server refused our key

The first 13 steps are quite obvious, but it took me some time to notice that you really have to use the hostname. Before when I was just using a local IP address like 192.168.178.100 I could still login with putty, but the key would not be accepted, now that I’m using my hostname I can succesfully login on the server. There are a lot of tutorials like this one on the web, but none of them told me to use the hostname you have set up on your server!