30

I know that the public SSH key can be recovered from the private using ssh-keygen -y.

How can a (deleted) public key be recovered from the private key in GPG (preferably in a way that is OpenGPG compatible)?

1 Answer 1

36

"Recovering" Public Keys in OpenSSH

ssh-keygen -y does not actually recover the public key, but just reads it from the private key, where it is always attached if stored in OpenSSH format.

"Recovering" Public Keys in OpenPGP

Similar for OpenPGP: if exported in an OpenPGP-compliant way, the private key will always contain the public key - import it on a computer you own and trust, and export the public key afterwards. With GnuPG, do something like:

gpg --import [private-key-file]
gpg --export [key-id]

gpg --export will by default only export the public key.

Where the Public Key Also Might be Found

If you shared the public key, chances are high you either find it on public key servers (eg., http://pgp.mit.edu) or some friend of you has it on his computer (where he can easily gpg --export it).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .