Upon executing apt-key list, I see a key which I wish to remove.

pub   rsa2048 2017-11-24 [SC]
      3241 413F 3CE0 B919 E82F  DCA0 6239 92CF C9A9 7C2C
uid           [ unknown] John Doe <[email protected]>
sub   rsa2048 2017-11-24 [E]

man apt-key tells me that I may delete a key by executing apt-key del keyid. It also tells me that list (aka finger) will list trusted keys with fingerprints, so I am assuming that 3241 413F 3CE0 B919 E82F DCA0 6239 92CF C9A9 7C2C is the fingerprint and not the keyid. I've messed around with gpg --list-keys and gpg --list-public-keys, however, it doesn't list any keys but creates ~/.gnupg/ with various non-text files which do not display the key IDs.

How can I identify the keyid so I may delete the key?

PS. Before asking this question, I searched for a solution, and some recommend not using "short key ids". If I should not be deleting keys by the keyid as described by man apt-key, please provide the appropriate way.

1 Answer 1


The keyid is the last 8 characters of the gpg key's fingerprint, which is that long hex-code under pub

In your case it is: sudo apt-key del C9A97C2C


  • 2
    Thanks Mark, I had actually seen that post, but considering that man apt-key does not also mirror this information, it made me question whether I am actually doing this correct by using the frowned upon short key ID. Jan 31, 2018 at 14:10
  • 3
    Wow, that's seriously.... not obvious from the tools. Great answer, thanks. Aug 19, 2020 at 22:17
  • 2
    It seems it is also valid to use the whole ID string
    – yurtesen
    Nov 22, 2020 at 18:19
  • yeah, apt-key and gpg have some serious brainfarts when it comes to CLI UX Jan 21 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .