gpg error the following signatures couldn’t be verified

The post explains the quick fix of problem stating “gpg error the following signatures couldn’t be verified”. This issue we encountered while installing a package with apt-get command on Ubuntu 14.04 LTS Server.

GPG Error : How To Solve

The given below is real error which we found on our server while installing haproxy package, we have underlined the complete error:

GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 505D97A41C61B9CD .

In above you can see, the blue colored words.Actually, it is missing key looking by apt. In your case, the key may be different. You may have more than one key also which are missing.

Solution: Use the given below command syntax. And replace ‘missing public key’ with your actual key info in below given syntax.

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys [missing public key]

Example : Just like we have given ‘missing public key’ info in given below command line

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 505D97A41C61B9CD

Run the given below final command to update the system repo information.

sudo apt-get update

Example from real scenario :

root@ip-10-0-0-190:~# apt-get update
Ign http://us-east-1.ec2.archive.ubuntu.com trusty InRelease
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates InRelease
Hit http://us-east-1.ec2.archive.ubuntu.com trusty Release.gpg
Hit http://us-east-1.ec2.archive.ubuntu.com trusty Release
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/main Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/universe Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/universe Translation-en
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/main Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/universe Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/main amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/main Translation-en
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/universe Translation-en
Ign http://us-east-1.ec2.archive.ubuntu.com trusty/main Translation-en_US
Ign http://us-east-1.ec2.archive.ubuntu.com trusty/universe Translation-en_US
Get:1 http://ppa.launchpad.net trusty InRelease [15.4 kB]
Ign http://ppa.launchpad.net trusty InRelease
Ign http://ppa.launchpad.net trusty/main Sources/DiffIndex
Ign http://ppa.launchpad.net trusty/main amd64 Packages/DiffIndex
Hit http://ppa.launchpad.net trusty/main Translation-en
Hit http://ppa.launchpad.net trusty/main Sources
Hit http://ppa.launchpad.net trusty/main amd64 Packages
Ign http://ppa.launchpad.net trusty/main Translation-en_US
Hit http://security.ubuntu.com trusty-security InRelease
Get:2 http://security.ubuntu.com trusty-security/main Sources [101 kB]
Get:3 http://security.ubuntu.com trusty-security/universe Sources [31.9 kB]
Get:4 http://security.ubuntu.com trusty-security/main amd64 Packages [382 kB]
Get:5 http://security.ubuntu.com trusty-security/universe amd64 Packages [120 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Fetched 651 kB in 15s (42.2 kB/s)
Reading package lists... Done
W: GPG error: http://ppa.launchpad.net trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 505D97A41C61B9CD
root@ip-10-0-0-190:~# ls /etc/apt/
apt.conf.d  preferences.d  sources.list  sources.list.d  trusted.gpg  trusted.gpg.d
root@ip-10-0-0-190:~# ls /etc/apt/trusted.gpg
/etc/apt/trusted.gpg
root@ip-10-0-0-190:~# ls /etc/apt/trusted.gpg.d/
root@ip-10-0-0-190:~# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 505D97A41C61B9CD
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.4uI8adxCEb --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 505D97A41C61B9CD
gpg: requesting key 1C61B9CD from hkp server keyserver.ubuntu.com
gpg: key 1C61B9CD: public key "Launchpad PPA for Vincent Bernat" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
root@ip-10-0-0-190:~# apt-get update
Ign http://us-east-1.ec2.archive.ubuntu.com trusty InRelease
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates InRelease
Hit http://us-east-1.ec2.archive.ubuntu.com trusty Release.gpg
Hit http://us-east-1.ec2.archive.ubuntu.com trusty Release
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/main Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/universe Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://us-east-1.ec2.archive.ubuntu.com trusty-updates/universe Translation-en
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/main Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/universe Sources
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/main amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/main Translation-en
Hit http://us-east-1.ec2.archive.ubuntu.com trusty/universe Translation-en
Ign http://us-east-1.ec2.archive.ubuntu.com trusty/main Translation-en_US
Ign http://us-east-1.ec2.archive.ubuntu.com trusty/universe Translation-en_US
Hit http://security.ubuntu.com trusty-security InRelease
Get:1 http://ppa.launchpad.net trusty InRelease [15.4 kB]
Hit http://security.ubuntu.com trusty-security/main Sources
Get:2 http://ppa.launchpad.net trusty/main Sources [1,461 B]
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Get:3 http://ppa.launchpad.net trusty/main amd64 Packages [1,801 B]
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Get:4 http://ppa.launchpad.net trusty/main Translation-en [1,306 B]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Fetched 20.0 kB in 1s (10.2 kB/s)
Reading package lists... Done
root@ip-10-0-0-190:~#