How to use SSH keys with PuTTY

This article describes how to use PuTTY for passwordless SSH access via public/private key pairs.

  • Open the PuTTYgen utility which comes along the PuTTY suite of programs:
PuTTYgen1.png

  • Click on Generate to start generating a public/private key pair
  • You are asked to generate some randomness by moving the mouse on the area below the progress bar:
PuTTYgen2.png

  • When done the public key is shown and the Save buttons are enabled:
PuTTYgen3.png

  • Optionally you can enter a passphrase to protect your private key, please do so!
  • Click on "Save private key":
PuTTYgen5.png

  • Enter a name and select a destination folder, then click "Save". IMPORTANT: This file MUST reside on your computer and it cannot leave it or be sent over any network.
  • Do likewise for the public key (click on "Save public key").
  • Now go back to the PuTTYgen main screen and select the public key with the mouse, right click on the selection and copy it.
  • Open a new PuTTY session to the Linux machine you want to connect via those SSH keys.
  • At prompt, cd to .ssh/ folder:
authkey1.png

  • With a text editor of your choice, open the authorized_keys file. If not existing, an empty one will be created:
authkey2.png

  • Go to the end of file and paste the public key as a new line (middle or right mouse buttons click when in text editing mode):
authkey3.png

  • Save, exit and close the PuTTY session. Now you need to tell PuTTY to use the new key pair.
  • Go back to the PuTTY main window, load your saved session settings from the Session tab.
  • Go to Connection -> SSH -> Auth and click on "Browse":
PuTTYgen6.png

  • Select the private key file you saved previously and click "OK".
  • Go back to the Session screen, and save the new session settings for future use.
  • You are done! Try to connect: you should go straight to the shell prompt with no password request.

Possible issues

If you are still prompted for a password, try the following:

  • Make sure you did not miss any character in the copy/paste of the public key. If not sure, copy it again from the saved public key file and re-do the paste.
  • Check the authorized_keys permissions if creating a new file. They must be 644 (see the chmod man page).
  • Make sure your private key is loaded into the PuTTY session.

-- federico melaccio - 2014-07-11

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng PuTTYgen1.png r1 manage 29.9 K 2014-07-11 - 11:41 FedericoMelaccio  
PNGpng PuTTYgen2.png r1 manage 33.5 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng PuTTYgen3.png r1 manage 40.1 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng PuTTYgen4.png r1 manage 41.9 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng PuTTYgen5.png r1 manage 100.8 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng PuTTYgen6.png r1 manage 35.6 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng authkey1.png r1 manage 45.9 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng authkey2.png r1 manage 49.6 K 2014-07-11 - 11:42 FedericoMelaccio  
PNGpng authkey3.png r1 manage 40.3 K 2014-07-11 - 11:42 FedericoMelaccio  
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2016-04-19 - ChrisBrew
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback