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!

This entry was posted in Macs, Server Administration and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

20 Comments

  1. wwilliams
    Posted November 2, 2008 at 3:50 pm | Permalink

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

  2. Posted November 8, 2008 at 2:42 pm | Permalink

    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
    Posted January 6, 2009 at 1:42 pm | Permalink

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

  4. Kyle
    Posted January 12, 2009 at 11:49 am | Permalink

    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
    Posted January 13, 2009 at 10:12 am | Permalink

    Thanks, useful.

  6. Posted March 19, 2009 at 4:14 pm | Permalink

    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
    Posted May 8, 2009 at 7:24 am | Permalink

    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
    Posted May 13, 2009 at 1:48 pm | Permalink

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

  9. Posted May 15, 2009 at 7:52 pm | Permalink

    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
    Posted May 16, 2009 at 3:47 pm | Permalink

    Amazing tips!! Thank you Sir!!

    Alex

  11. Posted June 25, 2009 at 1:36 pm | Permalink

    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
    Posted September 16, 2009 at 8:08 pm | Permalink

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

  13. Posted October 23, 2009 at 10:11 am | Permalink

    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
    Posted October 25, 2009 at 12:29 am | Permalink

    Another satisfied visitor, you saved the day, much appreciated

  15. Josh
    Posted November 5, 2009 at 9:03 pm | Permalink

    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. Posted January 17, 2010 at 5:03 am | Permalink

    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
    Posted January 17, 2010 at 6:42 pm | Permalink

    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
    Posted February 26, 2010 at 9:19 pm | Permalink

    Thanks for the steps. This works great.

  19. Bandesz
    Posted February 26, 2010 at 11:05 pm | Permalink

    Thx for the info, it was very useful :)

  20. didge75
    Posted March 1, 2010 at 1:57 pm | Permalink

    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

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*