Listing Keys

Once you have imported keys, you can then list all of them by using the --list-keys option:

$ gpg --list-keys

This command lists both your private key (you usually have only one, but you can have as many as you like) as well as the public keys you have imported. An example of output from the command on a keyring that contains keys for James Stanger and Andy Oram would appear as follows:

pub  2048g/CC7877gh 2009-09-11 James (Stanger) <>
sub  2048g/89G5B4KM 2009-09-11

pub  2048D/4g37NJ27 2009-12-09 Andyo (Oram) <>
sub  2048D/4g37GK38 2009-12-09

The pub defines the DSA master signing key, and the sub defines the ElGamal encryption subkey.

If you wish to list just the private keys, or what GPG calls “secret keys,” use the --list-secret-keys option. To list just the public keys, use the --list-public-keys option.

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.