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)?
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.
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.
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).