Convert ppk to OpenSSH keypairs

.ppk files are created by PuTTY to store a private key generated by the program.

To convert keypairs, first you need to install the package putty and then:

Generate the private key:

puttygen id_rsa.ppk -O private-openssh -o id_rsa

Generate the public key:

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

SSH: No supported key exchange algorithms [preauth]

I’ve recently installed Solaris 11.4 on a VM and, as soon as I tried to log in remotely using SSH, my connection was refused straight away. First of all, I checked if the service was enabled:

$ svcs ssh
STATE          STIME    FMRI
online         13:23:15 svc:/network/ssh:default

I checked SSH directory under /etc and something was definitely not quite right with the auto-generated keys:

-rw-------   1 root     root         0 Jan  4 13:23 ssh_host_ed25519_key
-rw-r--r--   1 root     root         0 Jan  4 13:23 ssh_host_ed25519_key.pub
-rw-------   1 root     root         0 Jan  4 13:23 ssh_host_rsa_key
-rw-r--r--   1 root     root         0 Jan  4 13:23 ssh_host_rsa_key.pub

The keys were there… but truncated to zero.

Something, somewhere went wrong during the key generation (usually when OpenSSH is run for the first time) so I deleted the keys and restarted the service:

# svcadm restart ssh

The keys were re-generated and I was able to log in.

Convert .ppk key to OpenSSH keys

OpenSSH is the de facto standard implementation of the SSH protocol.

If you use ssh-keygen with the default options, it will generate a private and a public key that will work with virtually any server.

Unfortunately, out there are Windows users that bother Linux admins with .ppk key generated by PuTTY; both keys are stored in this single proprietary file.

You can convert this file and obtain standard OpenSSH key pairs using puttygen provided with the putty package available on many distros.

puttygen your_key.ppk -O [output-type] -o [output-file]

output-type refers to they key type, private-openssh or public-openssh.