How to fix GPG error NO_PUBKEY in Ubuntu
Sometimes, you can get an error like below when you use apt-get update command:
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://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.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
The reason is that the template is missing the public key for the Ubuntu repository. Our workaround is to create the missing key by using apt-get.
As the error message above, there are 2 codes to note: 40976EAF437D05B5 and 3B4FE6ACC0B21F32. If your code is different then copy it and replace it in the command line below:
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 40976EAF437D05B5
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 3B4FE6ACC0B21F32
Now, you can use the apt-get update command without bugs.