How To Convert Your Putty .ppk Private Key To A Normal SSH Key You Can Use On An Apple Mac

Also, how to connect to a server using SSH on a Mac

I spent ages trying to figure this out so that I could SSH onto my production hosting server from my iBook. Now that I know what was wrong, I can’t believe how long it took me to solve, because the answer is so simple – but unfortunately I never found anything in Google that helped me, it was only pure luck and dogged perseverance that helped me figure this one out.

I already knew that I could open an SSH connection on my Mac using Terminal, and I could SSH onto my production server from my XP pc using Putty with no problems.

So when I copied my .ppk Putty key from my PC to my Mac I expected to be able to type:

ssh -2 username@123.123.123.123 –i yourkey.ppk

from within Terminal and get straight onto my server with no questions asked.

But oh no! it’s not quite as easy as that – well these things never are, are they?

Let start with the very basics, you can find the Terminal program on your Macintosh in Applications -> Utilities.

Open it and you have something resembling a Windows DOS prompt.

Now if you already have a .ppk file from your PC that you want to convert to use on your Mac you need to visit the Putty Website www.chiark.greenend.org.uk/~sgtatham/putty/download.html and download puttygen.exe (on your PC) now open it, and using the File menu, load your .ppk that you already use, and type in your pass phrase.

Now go to the Conversions menu and export the key as an OpenSSH key – hey presto – you now have a key file that will work on your Mac! Such a simple solution, yet that took me so long to figure out …

Anyway, now you just need to copy your new .ssh keyfile over to your home (~) directory on your Mac and set the permissions to 700 (chmod 700 yourkey.ssh).

Once you’ve done all that you can use the ssh command.

				
ssh -2 username@123.123.123.123 –i yourkey.ssh
				

and you should be able to SSH onto your box as you would from your PC – amazing!

48 Responses to How To Convert Your Putty .ppk Private Key To A Normal SSH Key You Can Use On An Apple Mac

  1. wwilliams says:

    hey thanks for this post… cant believe i didn’t see that

  2. admin says:

    No probs! Glad to have helped, actually it seems this must be a common problem; since I first posted this it’s become the most popular page on the website and lots of similar articles have popped up all over the place.

  3. Ron says:

    Many thanks, wwilliams. This caused me so much frustration until I read your article. All sorted now. Thanks again!

  4. Kyle says:

    Companies keep sending me ppk files, assuming that Putty and Ssh are pretty much synonymous I have actually a been asked to “Putty in” before.

    Congrats for being the first result on Google for “ppk convert”, sorted that problem out nice and quickly for me :)

  5. J says:

    Thanks, useful.

  6. David Long says:

    Thanks so much for this. Was getting frustrated with all the mac SFTP clients that wouldn’t connect and had no idea why.

    Works like a charm now :)

  7. Arlen says:

    Yes, useful tip and not enough info on the web in general on such ‘obvious’ things
    However, it should also be noted this isn’t so OSX / mac related but more ‘putty’ vs ‘openssh’ which would be accurate for linux as well (might help search terms to have fedora, ubuntu, etc)

  8. dookka says:

    A little too late, perhaps, to save my sanity; but sir, thank you!

  9. This was VERY useful for me. I like to be able to instantly connect to my server using spotlight so i did the following:

    echo “ssh -2 username@123.123.123.123 -i yourkey.ssh” > instant
    chmod 777 instant
    ./instant

    Now whenever I use the command to launch spotlight and type “instant”, then enter, terminal automatically opens up and starts my session. Very basic, but very useful.

  10. Alex says:

    Amazing tips!! Thank you Sir!!

    Alex

  11. Philippe says:

    Thanks for the tip! Maybe we can add that it’s probably a good idea to give the private key the default name id_rsa. With thi, you don’t event have to use the -i option you show in your examples.

  12. alex says:

    excellent tip – was trying to openssh with a putty generated key and nothing was working until I found this. worked great

  13. Werner says:

    Many thanks – my administrator gave me a completly useless instruction, but this works and is exactly what I’ve been looking for!

  14. Mike Bergin says:

    Another satisfied visitor, you saved the day, much appreciated

  15. Josh says:

    Thank you for this post. I have been trying to figure out how to do this from my PC to my new Mac and after looking around on the internet, this was the first/last place that I should have went.

  16. Additionally, you can convert the .ppk on your Mac.

    You will need the “putty” package (needs xcode and macports), and then run the following from your command line:

    puttygen your_putty_key.ppk -O private-openssh -o id_dsa

  17. Kyle says:

    Awesome! This was incredibly useful and let me move to a Mac without having to update half a dozen public SSH keys in various places on the internet.

  18. Bennie Lunsford says:

    Thanks for the steps. This works great.

  19. Bandesz says:

    Thx for the info, it was very useful :)

  20. didge75 says:

    Oh Thank you so much

    Too much time testing with pub and priv key, dsa/rsa and so.
    But i was PUTTY, it works for suze too, normal you would say maybe.
    Thanks

    Enjoy

  21. jag says:

    Many thanks for this, and also to @Raphael for mentioning the MacPorts option!

    The puttygen cmd did indeed generate a private key identical to the one obtained from the PC app as described in this how-to, and they worked fine with ssh.

    There’s no way I would have figured this out on my own. THANK YOU!

  22. cmchao says:

    Very helpful. Thank you

  23. Periklis says:

    you saved my day, thanks!!

  24. a_monstr says:

    Thanx a lot, guy! Good howto)

  25. Britt says:

    Thank you!:)

  26. Igor Ganapolsky says:

    Terrific article! Thank you for the instructions on converting the ppk file. I woudn’t have figured it out.

  27. Dmitri says:

    Thank you!!!!
    I killed a half part of a day before found this solution

  28. anand says:

    hi,
    great post, thanks a lot!
    any idea a putty connection manager on mac. or how can i open multiple remote connections to different servers by just one click like in putty connection manager?

  29. ggkkrr says:

    First of all great post.
    In my case i do not have any password i have only yhe ppk key. But when i use -i it asks for the password. How to get ride of the password.

    Thanks,
    Gopala

  30. Gil says:

    Thanks! Been struggling with this, trying to transfer a working key on a PC to a Mac. These instructions were spot on.

  31. Mike Boylan says:

    This was incredibly helpful. A Windows systems admin sent me a key but generated it using PuTTY. I’m a Mac user, so needed it in OpenSSH. Had no idea how to convert it. Thanks a ton, man!

  32. FooLman says:

    Great article, thanks!

    Now somebody tell me, why on earth do putty folks need a different format for keys than the good standard pem?

  33. C. Sanchez says:

    Ty alot. One is never too old to learn.

  34. Vaibhav says:

    Works awesome. many thanks for sharing the tip.

  35. Tom says:

    you can also install putty via mac ports, if you are patient and don’t have a pc at hand. The mac ports install is simple, but for me runs really slow like 15 minutes….

    if you have macports installed just do this:
    sudo port install putty

    Thanks for the tips, just running the conversion now.

  36. David says:

    Amazing!!! it works really nice. thanks for putting that up!

  37. Girish says:

    It was very helpful for me and team!

  38. Girish says:

    Thank you so much for sharing it!

  39. Tomelec says:

    Thank you, this solved my issue easily!
    Got only a ppk file for login on a server and needed to use openSSH as Putty running under Wine is less fun ;)

  40. Paweł says:

    Great article, just that what I was looking for.
    Thank You :)

  41. Ash Young says:

    This just saved us a lot of pain, thank you!

  42. ACEB says:

    Thank you very much … the key convertion was very usefull but i couldn’t figure out what else i was missing as the command to ssh wont isn’t working … bump to another site http://stevewardell.wordpress.com/2009/11/26/use-your-putty-ssh-key-on-linux-or-mac/ … used that command and it worked for me …

    ssh -p port -i private_key_filename username@hostname_or_ip_address

    Thanks to both sites and contributors! Now i don’t have to open parallels just to use putty! hehe! :)

  43. Marcus says:

    thank you, works wifout probs :)

  44. Sarah Lewis says:

    Thanks so much for pulling this info together. Like a lot of the other commentors, I had a client send me a .ppk file and had no idea how to use it. Really appreciate that you didn’t just solve the problem and move on! :)

  45. andrey says:

    Thank you, that helped me :-)

  46. Murat says:

    Good tip, man!

    +10 karma points to you!

  47. Tomtom says:

    Welll thanks for the post but I also encountered another problem and will share the solution to help others.

    I could generate my ssh2 key fine with puttygen, but then when I went to the folder: impossible to see it (I am on windows 7 by the way). As I am administrator, I ticked “show hidden files”, tried to change the permission (through the puttygen save-as dialog, which was the only place where I could actually see the file), but to no avail. IMPOSSIBLE TO SEE THE BLOODY FILE!

    Actually I haven’t found why but I have found a workaround: delete the ssh2 exported key file through the putty gen save-as dialog, then go to the recycle bin, restore the file: now it is a normal file…

    Hopefully this can help someone and save him an hour of frustration