Saturday, October 8, 2011

How to Remove RPM GPG Public Key


Public keys can be erased after importing just like packages. Here's how to
remove the CentOS GPG public key:

rpm -e <GPG public key>

[root@localhost]# rpm -qa gpg-pubkey*
gpg-pubkey-e8562897-459f07a4
[root@localhost]# rpm -e gpg-pubkey-e8562897-459f07a4
[root@localhost]# rpm -qa gpg-pubkey*
[root@localhost]#

If there are duplicates exist:


For example, Import the same key two times

[root@localhost]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@localhost]# rpm -qa gpg-pubkey*
gpg-pubkey-e8562897-459f07a4
[root@localhost]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@localhost]# rpm -qa gpg-pubkey*
gpg-pubkey-e8562897-459f07a4
gpg-pubkey-e8562897-459f07a4

Now try to remove Public Key, You will get error message like this:

[root@localhost]# rpm -e gpg-pubkey-e8562897-459f07a4
error: "gpg-pubkey-e8562897-459f07a4" specifies multiple packages

How to solve this:


Use --allmatches switch along with -e, It removes all versions of the package
which match PACKAGE_NAME(Public Key ).

[root@localhost]# rpm -e --allmatches gpg-pubkey-e8562897-459f07a4
[root@localhost]# rpm -qa gpg-pubkey*
[root@localhost]#

2 comments:

  1. awesome man. that helped me a lot. keep helping...

    ReplyDelete