Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

`gpg --list-keys` does not list my keys

Writer Sophia Terry

I've added a lot of keys to my Ubuntu 20.04 computer and when I issue the gpg --list-keys command in my terminal I only get silent output (ie nothing is returned). sudo gpg --list-keys doesn't list any of my keys either. What am I doing wrong?

1

1 Answer

When a user uses gpg or gpg2 to import public keys, the keys are stored in the public keyring that is in ~/.gnugpg by default. If you used apt-key the public keys are stored in individual .gpg files in /etc/apt/trusted.gpg.d/. The following command will run the gpg command without arguments for each gpg file in /etc/apt to cover some case where the name of the folder is different. Gpg guesses what output you want based on the content of the file passed as argument:

find /etc/apt/ -name \*.gpg | xargs -n 1 gpg

The following alternative command sets each file as the keyring and ignores the default keyring, this way you can replace the --list-public-keys by --export --armor to export public keys to text format:

find /etc/apt/trusted.gpg.d/ -type f | xargs -n 1 gpg --no-default-keyring --list-public-keys --keyring

9

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy