It is quite easy to configure Putty to login to a server using a public/private key pair.
- Create the key pair
- Preparing the remote server
- Use the copy that you still have in your clipboard
- Make a new copy of the existing key
- Prepare Putty to use the new key pair.
- Open putty and either create a new connection or load an already existing one
- Set the user name to the name that you want to login as.
- Amend the key settings.
- Save your settings
- Test the new connection
Open the Puttygen.exe file and create a 1024 bit RSA-SSH2 key. After the keys have been created save them in a save place. Optionally you can give your private key a passphrase.
The important part here is that you have to copy the key that is showing in the textbox in using the context menu in puttygen. Selecting the key with the mouse and copying to the clipboard using CTRL-keys will not work. So with the content of the public key in your clip board you can close puttygen.
There are several examples on the internet in how to assign your public key to the remote server but some of them are rubbish. I followed one just to end up with this error message.
So to avoid an error message like the one above there are two ways to apply the key to the remote machine.
Login to the remote server as the user that you want to use for passwordless login. Execute echo "ssh-rsa the content of your clipboard" >> .ssh/authorized_keys
The double quotes and the prefix “ssh-rsa ” are necessary.
Open the public key in an editor like notepad++.
Before we can echo the key into the authorized_keys file on the remote server we have to amend it slightly. The part that we are interested is starts with AAAA and ends with V7U=. That is your public key. Make sure that the whole key is not wrapped. So at the end you should have a long line starting with AAA and ending with 7U=. Now add the prefix ssh-rsa followed by a space to the beginning of that line. To make it easy to find the key in the file you can also add the comment at the end of the line. Key and comment must be separated by a space. So your final line is now starting with ‘ssh-rsa AA…’ and ending either with ‘…7U=’ or ‘…7U= myWorkstation’ or whatever comment you chose. Now surround the whole line with double or single quotes and copy it to the clipboard. Use the above command to add the key to the authorized_keys file.
- That is all you need to do on the remote server.
After opening the connection to the remote server you should see an output that is similar to this one.
I hope that this will help.