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!
hey thanks for this post… cant believe i didn’t see that
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.
Many thanks, wwilliams. This caused me so much frustration until I read your article. All sorted now. Thanks again!
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
Thanks, useful.
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
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)
A little too late, perhaps, to save my sanity; but sir, thank you!
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.
Amazing tips!! Thank you Sir!!
Alex
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.
excellent tip – was trying to openssh with a putty generated key and nothing was working until I found this. worked great
Many thanks – my administrator gave me a completly useless instruction, but this works and is exactly what I’ve been looking for!
Another satisfied visitor, you saved the day, much appreciated
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.
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
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.
Thanks for the steps. This works great.
Thx for the info, it was very useful
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
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!
Very helpful. Thank you
you saved my day, thanks!!
Thanx a lot, guy! Good howto)
Thank you!:)
Terrific article! Thank you for the instructions on converting the ppk file. I woudn’t have figured it out.
Thank you!!!!
I killed a half part of a day before found this solution
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?
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
Thanks! Been struggling with this, trying to transfer a working key on a PC to a Mac. These instructions were spot on.
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!
Great article, thanks!
Now somebody tell me, why on earth do putty folks need a different format for keys than the good standard pem?
Ty alot. One is never too old to learn.
Works awesome. many thanks for sharing the tip.
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.
Amazing!!! it works really nice. thanks for putting that up!
It was very helpful for me and team!
Thank you so much for sharing it!
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
Thaks!
Great article, just that what I was looking for.
Thank You
This just saved us a lot of pain, thank you!
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!
thank you, works wifout probs
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!
Thank you, that helped me
Good tip, man!
+10 karma points to you!
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