Fix apt-get update
Fix apt-get update “the following signatures couldn’t be verified because the public key is not available”
One day, as I worked on code for a project, from the Windows WSL shell, running Ubuntu, I executed : apt-get update
. The result was something close to the following :
[goldenboy@WEBXPS: ~]$ apt-get update Ign http://security.ubuntu.com trusty-security InRelease Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B] ... Fetched 21.9 MB in 14s (1,537 kB/s) Reading package lists... Done W: GPG error: http://security.ubuntu.com trusty-security Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32 W: GPG error: http://archive.canonical.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32 W: GPG error: http://archive.ubuntu.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32 W: GPG error: http://archive.ubuntu.com trusty-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32 [goldenboy@WEBXPS: ~]$
Houston, we have a problem. Let's try that again with sudo
[goldenboy@WEBXPS: ~]$ sudo apt-get upgrade Reading package lists... Done Building dependency tree... Done Calculating upgrade... Done ... E: Some packages could not be authenticated [goldenboy@WEBXPS: ~]$
The command line tool apt
works with Ubuntu's Advanced Packaging Tool (APT). It references a set of public encryption keys to verify trusted repositories listed in sources.list.
Apparerntly, these can get out of sync if an update is interrupted before it completes. Also, I wasn't entirely certain of a few of the repositories listed in sources.list. To play it safe,
I wiped and rebuilt the sources.list file using this site : Ubuntu Sources List Generator
The errors apt is raising are public key related : 40976EAF437D05B5
. Note : There can be multiple errors with the same key.
To add a missing key, run the following command (replacing the key from your error message):
[goldenboy@WEBXPS: ~]$sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.QTeppiINUh --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com gpg: key 437D05B5: public key "Ubuntu Archive Automatic Signing Key" imported gpg: Total number processed: 1 gpg: imported: 1 gpg: imported: 1 (RSA: 1) [goldenboy@WEBXPS: ~]$
Run for each unique key value in your errors.