Home > Linux > How To Use Putty with an SSH Private Key Generated by OpenSSH

How To Use Putty with an SSH Private Key Generated by OpenSSH

I have access to a remote server where I am only allowed to login via SSH with a key, and I can’t add an extra key by myself, as described in “No Password SSH” post. The private key (RSA) has been generated with ssh-keygen in Linux, and I can login from Linux without issue.

This morning, I wanted to do the same with Putty in Windows XP, so I just copied the private key to Windows and loaded it in Putty, but it failed:

After a few minutes of research, I found my answer on UbuntuForums, and the reason it fails is because Putty does not support openssh keys, but uses its own format.

Here’s what I had to do:

  1. Convert OpenSSH private key to Putty private key with Putty Key Generator (puttygen)
    Start puttygen, and click on Conversions->Import key, then click Browse and select the private key generated with openssh (e.g. id_rsa).
    Then click on Save private key (e.g. id_rsa_putty.ppk)
  2. Putty SSH login with private key.
    Now you can start Putty, enter the machine IP address or url as usual, then go to Connection->SSH->Auth.
    Click Browse, and select your private key file (e.g. id_rsa_putty.ppk), go back to Session and save the session. You should now be able to login to the server.

  1. Adrián
    October 14th, 2013 at 17:31 | #1

    Thank you, clear and useful !!

  2. November 23rd, 2013 at 17:24 | #2

    Awesome, worked like a charm, this was driving me batty!

  3. January 31st, 2014 at 07:36 | #3

    Thank You. I have been struggling to make the openssh 2 key to work with putty until I found your post.

  4. Agustin
    February 1st, 2014 at 01:48 | #4

    Hello and thank you for the step by step guide. I have an issue, though, just at the beggining. When importing the key with puttygen I get an error message “Couldn’t load private key (unexpected end of file)” and cannot continue past that point. Any ideas regarding this error? Than you in advance!

  5. Agustin
    February 1st, 2014 at 01:56 | #5

    Nevermind, I just resolved it. I think the problem was that the key file name was not standard (I’m not sure yet)

  6. Neth
    April 30th, 2014 at 00:59 | #6

    Nice work, helped a ton!!

  7. Kripal Kashyap
    August 29th, 2014 at 15:46 | #7

    It did not work for me, i did all the same steps given above to connect to my remote server.
    I am getting exception as “server refused our key “. Any suggestion is welcome.

  8. Angelo
    November 16th, 2014 at 23:25 | #8

    Awesome. really useful

  9. Zenlooks
    December 3rd, 2014 at 04:01 | #9

    Thanks guys. I have a id_rsa generated on linux machine and have to use it on windows machine using psftp of putty. I followed your conversion and everything is ok now. Thanks

  10. Steen
    May 5th, 2015 at 16:31 | #10

    Did the job perfectly. Thanks!!

  11. Wilian
    July 28th, 2015 at 05:36 | #11

    Thank a lot for this, it helped perfectly.

  12. ILambert
    October 21st, 2015 at 22:57 | #12

    Fantastic, that’s a really nasty gotcha. You’d think putty could do some validation of the key on the local machine and spit back a more useful error. Oh well, thanks again for the help!

  13. Hai
    November 19th, 2015 at 03:11 | #13

    Thanks so much, I almost flipped out

  14. Aksh
    December 17th, 2015 at 16:46 | #14

    Hey i tried with ur solution now i m getting another error like server refused the key can you help me how to solve this error and connect to server?

  15. tk2
    July 21st, 2016 at 19:28 | #15

    Thank you for this information.
    I spent like 2 hours trying to figure out why putty wont connect.

  16. K
    August 1st, 2016 at 21:53 | #16

    Thank you .. this worked..

  17. Anon
    August 26th, 2016 at 15:26 | #17

    I wish this had worked. Putty is not good software.

  18. M
    September 11th, 2016 at 09:08 | #18

    Hi everyone. For those getting “server refused” errors, the second step to this process, at least on Ubuntu on Digital Ocean, is that your server needs to have the PUBLIC part of the key pasted into a file called authorized_keys which is located in the ~/.ssh/ folder. The whole key needs to go on first line and only be one line long. Finally, success!

  19. Peter Parker
    February 1st, 2017 at 22:17 | #19

    You rock! Thanks for publishing clear and easy steps to follow. This totally worked for me.

  20. sneha
    September 20th, 2017 at 11:35 | #20

    Thanks a lot!! Very helpful, I was stuck with this for days and your solution resolved my issue.

  1. August 21st, 2013 at 02:58 | #1