gpg keys in linux

How to List GPG Keys in Linux

GPG (GNU Privacy Guard) is a powerful implementation of OpenPGP standard used for encryption & decryption. It uses GPG keys for authentication, verification as well as secure transmission of information across systems and applications. Sometimes you may need to list all GPG keys in your system. In this article, we will learn how to publish public as well as private GPG keys in your system, along with their signatures and digital fingerprints.


How to List GPG Keys in Linux

Here is how to list public as well as private GPG keys in Linux.


How to List Public GPG Keys in Linux

You can easily view all public GPG keys on your system using –list-keys option.

$ gpg --list-keys

The above command will list all public keys present in public keyring, in accordance with specifiers or options, if any. Public keyring contains all public keys along with their certificates. The above command will display public key “pub”, User ID “uid” and Subkey “sub”.


How to List Private GPG Keys in Linux

If you want to view a list of all private keys, use –list-secret-keys option. The private keys are encrypted and stored in secret keyring.

$ gpg --list-secret-keys

The above command will display Secret key “sec”, User ID “uid”, and the Secret subkey “ssb” in the output.

Also, the above command will display keys in short format. If you want to display information in long format, use the –keyid-format option.

$ gpg --list-secret-keys --keyid-format LONG


How to List Public GPG Keys with Signature in Linux

Digital signature is a system used to validate any document, message, data or email. If you sign it with a secret key to create a digital signature, then the recipient can verify your file using your public key.

If you want to list all public GPG keys along with their associated signatures, use the –list-sigs option.

$ gpg --list-sigs

The above command will list public key “pub”, user id “uid”, subkey “sub”, and signature “sig”.


How to List Public GPG Keys with Fingerprints

Fingerprint is a string of alphanumeric characters used to identify a long public key. It is used to differentiate one public key from another. You can use –fingerprint option with gpg command to generate a key’s fingerprint. Here is a command to generate a GPG key’s fingerprint and store it in a fingerprint file.

$ gpg --fingerprint > fingerprint

You can view the fingerprint using cat or any other command.

In this article, we have learnt how to list GPG keys in Linux.

Also read:

How to Find Oldest File in Directory
How to Show Disk Usage Only for Top Level Directories
How to Resolve bin/sh 1: source not found
How to Reload etc/hosts in Linux
How to Kill Stopped Jobs in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *