2

I have few GnuPG keys: test, test2, some test. When I invoke gpg --fingerprint test, fingerprints of all keys are listed. When I run gpg --fingerprint test2, only test2 key fingerprint is printed. How can I list fingerprint only for key named test?

From the GnuPG manual page

--fingerprint [=names=] List all keys with their fingerprints. This is the same output as --list-keys but with the additional output of a line with the fingerprint. May also be combined with --list-sigs or --check-sigs. If this command is given twice, the fingerprints of all secondary keys are listed too.

Jens Erat
  • 23,446
  • 12
  • 72
  • 96
ctomek
  • 275
  • 4
  • 11

1 Answers1

1

The relevant part of the documentation (man gpg) is the chapter "HOW TO SPECIFY A USER ID", pretty much at the end of the manual page.

The default mode is substring matching, which is what you observe (test2 contains the substring test).

By substring match.

This is the default mode but applications may want to explicitly indicate this by putting the asterisk in front. Match is not case sensitive.

Heine
*Heine

You want to use exact matches instead, where you have the options of matching words, a mail address or the whole user ID string depending on your specific needs:

By exact match on OpenPGP user ID.

This is denoted by a leading equal sign. It does not make sense for X.509 certificates.

=Heinrich Heine <heinrichh@uni-duesseldorf.de>

By exact match on an email address.

This is indicated by enclosing the email address in the usual way with left and right angles.

<heinrichh@uni-duesseldorf.de>

By word match.

All words must match exactly (not case sensitive) but can appear in any order in the user ID or a subjects name. Words are any sequences of letters, digits, the under‐ score and all characters with bit 7 set.

+Heinrich Heine duesseldorf
Jens Erat
  • 23,446
  • 12
  • 72
  • 96