3

Convert a PuTTY private key to openssh

 2 years ago
source link: https://ma.ttias.be/convert-putty-private-key-to-openssh/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Convert a PuTTY private key to openssh

Mattias Geniar, February 22, 2020

Follow me on Twitter as @mattiasgeniar

I recently got a PuTTY private key sent to me that I wanted to use to log into a remote server. But, I run OpenSSH, not PuTTY.

Here are the steps to convert the PuTTY private key to an OpenSSH private & public key.

Install puttygen

There’s a CLI tool to help with the conversion, it’s available on most Linux distro’s and Mac.

For Linux:

$ apt-get install putty-tools
$ yum install putty

On Mac:

$ brew install putty

On Mac, I ran into the error that PuTTY isn’t compatible with pssh, so I had to run brew unlink pssh first.

Now you have a utility puttygen available.

Converting the private key from PuTTY to OpenSSH

With your private key at hand, now run the following commands.

$ puttygen putty.ppk -O private-openssh -o ~/.ssh/id_putty
$ puttygen putty.ppk -O public-openssh  -o ~/.ssh/id_putty.pub
$ chmod 0600 ~/.ssh/id_putty
$ chmod 0666 ~/.ssh/id_putty.pub

You can put these files in your ~/.ssh folder to easily refer to them when you SSH into a machine.

$ ssh user@ip -i ~/.ssh/id_putty

With the -i flag you pass along the identity you want to use to authenticate, in this case we refer to the newly created private key.


Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK