Skip to content

Share this post

paypalkofibuymeacoffeemomo

How to generate the public key in another format from SSH private key?

Problem

I want to generate public key in PEM/PKCS8 format from SSH private key.

Solution

Update your code looks like this:

sh
ssh-keygen -f {path_to_ssh_private_key} -e -m {output_format} > {path_to_output_key}
ssh-keygen -f id_rsa -e -m PEM > id_rsa.pem
ssh-keygen -f id_rsa -e -m PKCS8 > id_rsa.pem

For more information, you can read the manual:

sh
man ssh-keygen