Posted 2003-08-23T14:35:00+01:00 in recipe

Setting up PuTTY and OpenSSH with public/private keys

I had to follow this strange recipe to get the latest PuTTY (0.53b) to work with SSH 2 RSA Public/private key pairs, and a recent OpenSSH (3.4p1):

  1. Get a shell on a box with OpenSSH
  2. Create a key pair: `ssh-keygen -t rsa'
    Remember the passphrase
  3. Move both generated files from the ~/.ssh directory to your local PuTTY directory in Windows.
  4. Run PuTTY Key Generator (puttygen.exe) and import the key you just generated:
    Conversions > Import key
  5. Edit the "Key comment" so that it stands out from your other keys, e.g. "Key-for-all-local-systems"
  6. Click the "Save public key" button to create a public key file.
  7. Click the "Save private key" button to create the private key file.
  8. Select the text in the Public view in the PuTTY Key Generator window, and copy the text to the clipboard.
  9. Create a new file on your remote computer at ~/.ssh/authorized_keys
  10. Open the file and paste the clipboard in the file (Shift+Insert usually); Now save that file.
  11. Make sure that you set the "Auto-login username" field for your remote connection in the PuTTY Configuration dialog for that connection. PuTTY will hint the SSH server that it should look for a public key in the authorized_keys file of the user in that field.
  12. Start the PuTTY Agent (pageant.exe), you will see a computer-with-a-hat icon in your system tray.
  13. Click on "View keys", and "Add key". Now select the private key file you generated earlier. Enter the passphrase
  14. That should be it. Try it out by selecting the saved connection from PuTTY Agent. You should be logged on to the system without providing a password.
  15. Obviously, this only makes sense if you now add the public key text to the authorized_keys file on all the remote systems you want to log on to with this pair.