Use your PuTTY SSH Key on linux or Mac

26 11 2009

I look after an ever growing number of linux servers as part of my job, almost all of this I do remotely and with the help of our data centre.

All remote access is by secure keys NOT passwords. I use PuTTY SSH terminal on windows so I wanted to use the same key on my linux desktop with, as it happens, Gnome Terminal. I could have just generated a new key pair on linux but that seemed silly.

First export your PuTTY key using PuTTYGen Conversions option and Export as OpenSSH key. Save the file with a sensible name. This is your PRIVATE key, this is the part you DO NOT give out. If this ever does get out in the wild you need to remove the public key from all servers and build a new key pair. If you don’t have a password/pass-phrase on your key you should add one.

Now copy the exported private key to your linux (or Mac, its exactly the same process) home folder, or where ever.

OK, you now have your private key on your linux desktop (or Mac), you need to set the right file permissions on it, ‘chmod 700 private_key_filename’, if you don’t do this it wont work (and the number of times I’ve missed this part…)

Now you should be able to SSH into your server

ssh -p port -i private_key_filename username@hostname_or_ip_address

-p port — on my servers I run the SSH daemon on a different port to 22, if you use 22 you can omit that part

-i private_key_filename — is your key that you just copied

username — is the username on the server you are connecting to, if its the same as the username on your linux (or Mac) desktop then you can omit it

hostname_or_ip_address — obvious

About these ads

Actions

Information

5 responses

31 01 2010
Use a PuTTY generated key on Mac OSX « Blogalhost

[...] I found this guide useful. [...]

31 03 2011
ACEB

Thank you very much … command worked for me …
Now i don’t have to open parallels just to use putty! hehe! :)

20 02 2012
skybert

Hi, thanks for the guide!

For all the Linux users out there, I’d like to mention that Wine runs puttygen.exe just fine, so you don’t need Windows to get your PuTTY keys converted to OpenSSH format.

6 03 2012
Tian Chu

This helped me out!!!

11 01 2013
Yazmin

Thank you! This was exactly the information I needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: