Home » Cryptography8 October 2015

GPG: Remove keys from your public keyring?

Your public keyring becomes a long list after you go on importing other peoples’ keys into your system. Later on you might feel to delete some of them which are unnecessary.

You can do so (delete keys from your public keyring) with the following command:

You can find the key-ID by listing your keys with the following command:

This will list all your keys in your keyring. Below is an example of a key:

pub 2048R/C5DB61BC 2015-04-21
uid Your Name (Optional Comment)
sub 2048R/18C601D3 2015-04-21

Note: They key-ID in above key example is C5DB61BC.

You can delete multiple keys with the following command:

However, this will ask for confirmation before deleting each key.

Deleting your own key

You might also want to delete any key created by you yourself. When you generate keys then both public and private keys are generated.

You will get the following error message if you try to delete your public key with –delete-key command:

gpg –delete-key key-ID

gpg: there is a secret key for public key “key-ID”!
gpg: use option “–delete-secret-keys” to delete it first.

This means that if you have private key of a public key then you need to delete the private key first.

You can first delete the private key:

After that, you can delete the public key:

Hope this helps.
Thanks.

Cryptography

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed

Comments are closed.