extracting a public key from the secret key

David Shaw dshaw@jabberwocky.com
Fri Aug 8 20:25:31 2003


On Fri, Aug 08, 2003 at 10:05:41AM -0700, vedaal@hush.com wrote:
> 
> there was a question that came up on another list, about somone who,
> by mistake, deleted a public key from his keyair
> 
> is there any way in gnupg to extract the public key from the secret one?

Yes.  All OpenPGP secret keys contain an internal copy of the public
key.  Do this:

gpg --export-secret-key thekey > sec.gpg
gpgsplit --no-split --secret-to-public sec.gpg > pub.gpg
gpg --import pub.gpg

In 1.3.x, you can do:

gpg --import-options convert-sk-to-pk --import secret-key.gpg

David