7.10. Adding Keys to Your Keyring

Problem

You want to add a public or secret key to your keyring.

Solution

If the public key is in the file keyfile:

$ gpg --import keyfile

If the secret key is in the file keyfile:

$ gpg --import --allow-secret-key-import keyfile

Discussion

Importing the secret key implicitly imports the public key as well, since the public key is derivable from the secret one.

See Also

gpg(1).

Get Linux Security Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.