1

I have a GPG public key key.gpg in binary format. I would like to convert this to ASCII so that the resulting file has the header

-----BEGIN PGP PUBLIC KEY BLOCK-----

The process I am setting up to do this does not have access to the usual central key store, so I cannot import and then export.

What is the GnuPG (version 2) command to do this?

0
gpg --enarmor < key.gpg > key.asc

should do the trick.

| improve this answer | |
  • That puts the header -----BEGIN PGP ARMORED FILE----- rather than the one I wanted. If the only difference is the header I suppose I could just change that manually... – rlandster Jan 10 at 18:02
  • True that. This is probably due to the fact that the enamor command is supposed to handle arbitrary data, not just key files. You should be save just editing the Begin and End lines (even if the receiving end does care about those at all). – Burnus Jan 10 at 19:52
0

Perhaps you can just create another, temporary keyring to import and export the key like this:

gpg  --keyring /tmp/temp.gpg  --no-default-keyring --import key.gpg 
gpg  --keyring /tmp/temp.gpg  --no-default-keyring  --export -a

I don't find that elegant but it should work. Note that the second command exports all the keys present in the keyring to one single file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.