Take the 2-minute tour ×

I know that gpg --export -o pub.key -a "Username" exports a users' public key, but it doesn't seem to write a standard PEM format block.

Is there any way to export keys from gpg in PEM format?

share|improve this question

1 Answer 1

You need the gpgsm utility, but, yes, you can.

gpgsm -o secret-key.p12 --export-secret-key-p12 0xXXXXXXXX

It contains keys and certificates. Then you can split them with openSSL and transform it in .pem at the same time

openssl pkcs12 -in secret-key.p12 -nocerts -out gpg-key.pem
openssl pkcs12 -in secret-key.p12 -nokeys -out gpg-certs.pem
share|improve this answer

Your Answer


