logo

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

Posted on
Authors

Problem

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

Solution

Update your code looks like this:

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
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:

man ssh-keygen
man ssh-keygen