I have a few backed up public and private key files. How can I check which public key file corresponds to which private key file?
I had generated 2048 byte public and private GnuPG key pairs using
gpg --gen-key
To backup the public key(s), I exported them using
gpg --armor --output ~/gpg_keys_backup/<Public Key Id>-public.key --export <Public Key Id>
To backup the private key(s), I exported them using
gpg --armor --output ~/gpg_keys_backup/<Private Key ID>-private.key --export-secret-keys <Private Key ID>
How do I determine which backed up keys belong to a pair?
Best Answer
By listing the secret key file's contents, you can query which public key a secret key belongs to.
The last line quoted
keyid
contains the public key's long key ID.