62

How do I make GnuPG (specifically version 1.4.12) display the full, 64-bit (8-byte) key ID for a key on a keyring on my system?

Doing gpg --list-keys --fingerprint XXXXXXXX only displays the 32-bit portion of the key ID, which I already know, and the fingerprint (which at least in the past has not necessarily been the same as the key ID, although the rightmost 32 bits do match in this particular case).

Googling turned up some pages about the importance of specifying the 64-bit key ID to minimize the risk of collisions, and some GnuPG options which want or accept a long key ID, but I couldn't find anything about how to actually display the long key ID.

user
  • 30,336

5 Answers5

92

Alternatively you can use:

gpg --keyid-format LONG -k 0xDEADBEEF

Or:

gpg --keyid-format 0xLONG -k 0xDEADBEEF
Ben
  • 1,627
  • 13
  • 13
21

You can see the long key ID using the option --with-colons (yes, very intuitive).

To print only the long key ID, use something like:

$ gpg --list-keys --with-colons XXXXXXXX | awk -F: '/^pub:/ { print $5 }'
user
  • 30,336
14

Just to point out a sanely named option to remember,

GnuPG 2.2.13 on macOS Catalina 10.15.4, --list-signatures option displays the key ID as well:

$ gpg --list-signatures
hyunchel
  • 141
9
gpg --version                              

# gpg (GnuPG) 2.2.19
# libgcrypt 1.8.5

To get the Short KeyId of the existing keys. In the example below there is only 1 key and the short keyid is 567C9ABC, displayed after rsa4096

gpg --list-keys --keyid-format SHORT

#~/.gnupg/pubring.kbx #pub rsa4096/567C9ABC 2021-03-06 [SC]

The Long KeyId = 32FA0BE4567C9ABC

gpg --list-keys --keyid-format LONG
#pub   rsa4096/32FA0BE4567C9ABC 2021-03-06 [SC]

EDIT: the keyId could be obtained using either gpg --list-keys or gpg --list-secret-keys

Polymerase
  • 275
  • 4
  • 7
0

list all key with long id:

gpg --list-secret-keys --keyid-format=long
bachden
  • 101