258

I know that is possible to convert .ppk under puttygen in Windows, but how to do that on Linux? Is this possible ?

slhck
  • 235,242
marioosh
  • 3,651

4 Answers4

382

Do it with Putty.

  • Linux: with your package manager, install PuTTY (or the more minimal PuTTY-tools):
  • Ubuntu: sudo apt-get install putty-tools
  • Debian-like: apt-get install putty-tools
  • RPM based: dnf install putty or yum install putty
  • Gentoo: emerge putty
  • Archlinux: sudo pacman -S putty
  • etc.
  • OS X: Install Homebrew, then run brew install putty

Place your keys in some directory, e.g. your home folder. Now convert the PPK keys to SSH keypairs:cache search

To generate the private key:

cd ~
puttygen id_dsa.ppk -O private-openssh -o id_dsa

and to generate the public key:

puttygen id_dsa.ppk -O public-openssh -o id_dsa.pub

Move these keys to ~/.ssh and make sure the permissions are set to private for your private key:

mkdir -p ~/.ssh
mv -i ~/id_dsa* ~/.ssh
chmod 600 ~/.ssh/id_dsa
chmod 666 ~/.ssh/id_dsa.pub

If you have already tried to perform a 'git clone' operation you might need to do this also

chmod 666 ~/.ssh/known_hosts
52
ssh-keygen -i -f id_dsa_1024_a.pub > id_dsa_1024_a_openssh.pub
  • -i flag is import from other than openssh format
  • -f flag means read from input file

Source: a blogpost at burnz.wordpress.com

jous
  • 817
14

Get the private key:

open the .ppk file in puttygen:

puttygen ~/.ssh/id_dsa.ppk

export as openssh:

Conversions → Export OpenSSH key

Get the public key:

open like before the private key with puttygen, the public key is under public key for pasting into OpenSSH authorized_keys file

9

I prepared a Docker container to make life simpler:

docker run --rm \
           --network=none \
           --volume=/path/to/file.ppk:/tmp/id_dsa.ppk \
           --volume=/path/to/output:/tmp/out/ \
           czerasz/putty-tools

Where:

  • /path/to/file.ppk - local path to your ppk file
  • /path/to/output - local path to where the private and public key should be placed
Basilevs
  • 2,904
czerasz
  • 292