How to list public GPG keys in Linux
In the Linux system, you can use the “–list-keys” option with the GPG command for listing the GPG keys. The “gpg –list-keys” command prints out the public keys, specified with the help of key specifiers or options. If you do not add any other option in the mentioned command, the GPG will list all keys present in your public keyring. In the public keyring, public keys are maintained with certificates attesting to their trustworthiness:
The output of the above-given command will print out the Public key “pub”, the User ID “uid”, and the Subkey “sub”:
How to list private GPG keys in Linux
The private GPG keys are encrypted and stored in the secret keyring. If you want to list out your private GPG keys in the Linux terminal, then add the “–list-secret-keys” option in the “gpg” command:
Now, in your terminal, you will see the Secret key “sec”, User ID “uid”, and the Secret subkey “ssb”:
For listing the GPG keys in a long format, specify the “–keyid-format LONG” option in the “gpg” command:
How to list public GPG keys with signatures in Linux
A mathematical system used for validating any document, message, or email is known as a digital signature. Using the secret key if you sign a file or document, anyone with your public key can verify if some changes are made to the file.
The “–list-sigs” option is added in the “gpg” command for listing out the public keys and their associated digital signatures:
The “sig” represents the “signatures” in the following output:
How to list public GPG keys with fingerprints in Linux
Multiple public GPG keys can have the same properties, the only to differentiate between them is to compare the desired fingerprint to the fingerprints of both public keys. The fingerprint of a GPG public key is a sequence of bytes used to identify a longer public key. By checking the fingerprint, you can also identity of the key owner while signing a PGP key.
Using the “–fingerprint” GPG command option, you can generate a public key’s fingerprint. For instance, we will write out the following command for creating a “fingerprint” file that will store all information related to the public keys, including their fingerprints:
The error-free output declares that the specified information is successfully saved in the “fingerprint” file:
Now, we will check out the content of the “fingerprint” file by executing the cat command:
The fingerprint will be listed below the public GPG key “pub”:
Listing GPG helps you to view the keys present in your Public and Private keyrings. This GPG functionality permits you to check out the GPG keypair of a specific user from the list. Using the GPG command with the –list-keys option assists in listing out the GPG keypair on the Linux terminal. This write-up demonstrated how to list public and private GPG keys. Moreover, the procedure of listing the public keys with their associated signatures and fingerprints is also provided.