Correct me where I'm wrong. There are public and private (or secret) keys. A public and a private key make up a keypair. Some keypairs are bound to the other ones. The former are called subkeys, the latter master (or primary) keys. In spite of them being called keys, they are actually keypairs.
Keyrings are files. gpg-1.4.18
by default creates two keyrings: public (pubring.gpg
), and secret (secring.gpg
). Public keys go to a public keyring, private to a secret one.
Let's take /etc/apt/trusted.gpg
:
$ gpg /etc/apt/trusted.gpg
pub 4096R/68576280 2014-06-13 NodeSource <gpg@nodesource.com>
sub 4096R/AA01DA2C 2014-06-13
pub 4096R/86E50310 2016-10-05 Yarn Packaging <yarn@dan.cx>
sub 4096R/D50AF136 2016-10-05
sub 4096R/9D41F3C3 2016-10-05 [expires: 2017-10-05]
sub 4096R/FD2497F5 2016-10-30 [expires: 2019-01-01]
sub 4096R/B6FF4DE3 2017-09-10 [expires: 2019-01-01]
sub 4096R/88B63E1E 2019-01-02 [expires: 2020-02-02]
sub 4096R/69475BAA 2019-01-11 [expires: 2020-02-02]
pub 3072R/95BD4743 2019-03-18 DEB.SURY.ORG Automatic Signing Key <deb@sury.org>
sub 3072R/8059B8AC 2019-03-18 [expires: 2021-03-17]
Consider the Yarn Packaging key and its subkeys. First, all the keys listed are the public ones. And its public key has 6 public subkeys. Supposedly, the first subkey doesn't have expiry date specified.
Now if I do:
$ gpg -k --keyring /etc/apt/trusted.gpg
/etc/apt/trusted.gpg
--------------------
pub 4096R/68576280 2014-06-13
uid NodeSource <gpg@nodesource.com>
sub 4096R/AA01DA2C 2014-06-13
pub 4096R/86E50310 2016-10-05
uid Yarn Packaging <yarn@dan.cx>
sub 4096R/D50AF136 2016-10-05
sub 4096R/88B63E1E 2019-01-02 [expires: 2020-02-02]
sub 4096R/69475BAA 2019-01-11 [expires: 2020-02-02]
pub 3072R/95BD4743 2019-03-18 [expires: 2021-03-17]
uid DEB.SURY.ORG Automatic Signing Key <deb@sury.org>
sub 3072R/8059B8AC 2019-03-18 [expires: 2021-03-17]
I can see only Yarn Packaging's first and last two keys. (1) Why doesn't it show all the keys? There's also uid
line that shows user id, which is basically a key name. And as I said, trusted.gpg
contains only public keys.
But apt
for one shows longer key ids. (2) Why is that?
W: GPG error: https://dl.yarnpkg.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 23E7166788B63E1E
Let's take a look at a key I've generated for the purpose of this writing:
$ gpg -k
/root/.gnupg/pubring.gpg
------------------------
pub 2048R/454A8AB5 2019-03-25
uid Temporary Key (Comment to the Temporary Key) <temporary.key@gmail.com>
sub 2048R/763C1752 2019-03-25
$ gpg -K
/root/.gnupg/secring.gpg
------------------------
sec 2048R/454A8AB5 2019-03-25
uid Temporary Key (Comment to the Temporary Key) <temporary.key@gmail.com>
ssb 2048R/763C1752 2019-03-25
So I've got two keypairs, or 4 keys. One master (or primary) key (or keypair). And one subkey (or subkeypair). 2 (public) keys in public keyring, and 2 (private) in the secret one. (3) Why do I automatically get a subkey?
pub - public key
sub - subkey
sec - private (or secret) key
ssb - private (or secret) subkey
uid - user id
(4) Are there other ways to display information about keys?