How to Fix ‘GPG key retrieval failed’ Error during YUM Install?

I was trying to install a package using yum and hit with an error : GPG key retrieval failed: [Errno 5] OSError: [Errno 2] No such file or directory: ‘/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL’. I understand that yum is trying to locate GPG keys for EPEL repository under /etc/pki/rpm-gpg/ and failed because of a missing file.

Solution:

From the error message, it was clear that yum is trying to read a file ‘RPM-GPG-KEY-EPEL’ under /etc/pki/rpm-gpg/ and when it could not find one, failed with the above error message. It means, there is an EPEL repository configured and its configuration is pointing to GPG keys of EPEL (which is actually missing).

add gpgkey to yum

Open repo configuration file and set correct value for gpgkey attribute.

# cd /etc/yum.repos.d/
# ls -l epel.repo

Lookout for ‘gpgkey‘ attribute and its value. The value of the ‘gpgkey‘ would be the file that was seen in the error message. For example, ‘/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL‘.

Couple of ways to solve this issue:

  1. Point ‘gpgkey‘ directly to the EPEL GPG Key: gpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL
  2. (or) download the EPEL GPGKey file and store it in /etc/pki/rpm-gpg/
    1. #cd /etc/pki/rpm-gpg
    2. wget https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL

Once done, try yum install and you should see a warning message as below:

# yum install git
::::::::::::::::::::::::::::::
Importing GPG key 0x217521F6 "Fedora EPEL <epel@fedoraproject.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
::::::::::::::::::::::::::::::::

As seen in the above snapshot, input “y” to import the GPG Key and start the installation of the package.

Updated on September 2, 2017

Was this article helpful?

Related Articles

Leave a Comment