Ubuntu – How to verify if a exported gpg key is a public or a private one

gnupg

If I've exported a gpg key using the command line, how can I verify if the exported key is a public one? I'm interested in both, a binary format and the armored format as well. I'm just a little bit scared to accidentally publish my private key. Thanks for your help

Best Answer

Run on the command line:

gpg the-keyfile

With the-keyfile being the .asc (armored) or .pgp (binary) file. The output will either start with sec (secret available) or pub (public key only). This is a successful export of a secret key:

sec  [more key details]
ssb  [more subkey details]

And this for a public key:

pub  [more key details]
sub  [more subkey details]

Note that exporting the secret key also implies the public key (one can derive the public from the secret).