GnuPG Command – How to Show Key Info from File

gpg

When I run gpg --with-fingerprints --with-colons keyfile.key, I get a machine parsable output on stdout containing the key fingerprint for the key inside the keyfile (which is exactly what I want), plus the following error on stderr:

gpg: WARNING: no command supplied.  Trying to guess what you mean ...

So GnuPG is guessing the command correctly, but for my life I can't figure out what command it is guessing. I have tried almost all of the commands listed on the man page. I'm using GnuPG 2.2.

Does anybody know the correct command to read a key file and show information about the key?


Edit: Ideally the mechanism would be able to read the keyfile from stdin, such as

cat keyfile.key | gpg --some-command

I should have mentioned this earlier but so many commands for gpg work with stdin I didn't even consider it a relevant constraint.

Best Answer

The good folks at the gnupg-users@gnupg.org mailing list had the answer:

For versions >= 2.1.23:

cat keyfile.key | gpg --with-colons --import-options show-only --import

For versions >= 2.1.13 but < 2.1.23:

cat keyfile.key | gpg --with-colons --import-options import-show --dry-run --import
Related Question