GPG:从您的公共密钥环中删除密钥?

阅读:605

Mukesh Chapagain 2016-06-06 00:00:00    Mukesh Chapagain笔记


在将其他人的密钥导入系统后,您的公钥将变成一个长列表。后来你可能会觉得删除一些是不必要的。

您可以使用以下命令(从您的公钥匙删除密钥):


1

gpg --delete-key key-ID


您可以使用以下命令列出键来查找键ID:


1

gpg --list-keys


这将列出您的钥匙圈中的所有钥匙。下面是一个键的示例:

pub 2048R / C5DB61BC 2015-04-21 
uid您的姓名(可选的评论)
sub 2048R / 18C601D3 2015-04-21

注意:上面关键示例中的key-ID是C5DB61BC

您可以使用以下命令删除多个键:


1

gpg --delete-key keyID1 keyID2 keyID3


但是,在删除每个键之前,将要求确认。

删除您自己的密钥

您可能还需要删除您自己创建的任何密钥。当生成密钥时,将生成公钥和私钥。

如果您尝试使用-delete-key命令删除您的公共密钥,您将收到以下错误消息

gpg -delete-key key-ID

gpg:有一个公共密钥“key-ID”的密钥!
gpg:使用选项“-delete-secret-keys”首先删除它。

这意味着如果你有一个公钥的私钥,那么你需要先删除私钥。

您可以先删除私钥:


1

gpg --delete-secret-key key-ID


之后,您可以删除公钥:


1

gpg --delete-key key-ID


希望这可以帮助。
谢谢。

分享这个:


GPG: Remove keys from your public keyring?

阅读:605

Mukesh Chapagain 2016-06-06 00:00:00


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:


1

gpg --delete-key key-ID


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


1

gpg --list-keys


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:


1

gpg --delete-key keyID1 keyID2 keyID3


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:


1

gpg --delete-secret-key key-ID


After that, you can delete the public key:


1

gpg --delete-key key-ID


Hope this helps.
Thanks.

Share this: