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!
20 Comments
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