I get the following error when i do sudo apt-get update

W: GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6AF0E940624A220

I tried following ways after reading various questions here and also by googling.

I tried

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF0E1940624A220

It did not help. I also tried

sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys

thinking port 11371(default) may be blocked due to firewall.

I also tried to reset everything as follows

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update && sudo apt-get upgrade

still i get the same error or get update. Any other possible solution I can try?

  • Have you tried all the solutions here? askubuntu.com/questions/13065/… – fossfreedom Jun 16 '13 at 8:45
  • Try: $ sudo apt-key adv --keyserver-options http-proxy=<proxy-server> --keyserver keyserver.ubuntu.com --recv 6AF0E1940624A220 – Marslo Jul 12 '17 at 9:36
up vote 73 down vote accepted

The second approach mentioned in this link worked for me. Manually download the key and add it. Hope that helps others too.


The link above provides detailed explanation with screenshots. It also has some other simple methods that could be tried before doing this manually. Since it is not accessible from some regions let me describe the method that worked for me : Youtube.

  1. Go to the OpenPGP Public Key Server. There you can enter your key into the Search String field, leaving everything else as is, then click "Search!".
    When searching for a key, always prepend 0x to it! This means that, for example, you have to search for 0x6AF0E1940624A220 instead of 6AF0E1940624A220.
  2. Click on the link provided in the pub section. This should take you to page containing the key. The page's heading should be similar to Public Key Server -- Get "0x6AF0E1940624A220"
  3. Copy everything from underneath the title (starting from -----BEGIN PGP PUBLIC KEY BLOCK-----) and save it in a file (e.g. key1).
  4. Once you have the file, run the following command

    sudo apt-key add key1
    

You will get an "OK" response.

And you are done. Repeat the procedure of other keys that might be missing.

  • May i ask you to describe that link here. It filtered for our country. – shgnInc Mar 13 '14 at 9:51
  • @shgnInc added the relevant part. – Aniket Thakur Mar 14 '14 at 19:22
  • 1
    Thnak you so much. – shgnInc Mar 14 '14 at 19:27
  • 1
    I signed in here just to upvote you. Thanks! – lev Feb 12 '15 at 3:31
  • For those bash challenged (most of us!) here is a script you can paste into a bash shell and press return to fix this problem for all keys: sudo apt-get update 2>&1 |\ grep NO_PUBKEY |\ sed -e 's?^.*NO_PUBKEY ??' |\ while read _hash; do \ wget -O- "keyserver.ubuntu.com/pks/lookup?op=get&search=0x${_hash}" |\ sudo apt-key add -; done – Michael Mikowski Dec 31 '16 at 18:32

This is a simplified version of Aniket's answer:

for fingerprint in 40976EAF437D05B5 3B4FE6ACC0B21F32; do
  curl "http://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x$fingerprint" | \
    awk '/-----BEGIN PGP/{p=1} /-----END PGP/{print; p=0} p==1{print}' > key.txt;
  sudo apt-key add key.txt;
done

Put as many keys as you need on that first line.

I included extraneous semicolons so that you can make this a one-liner to put into a Dockerfile. I have no idea why previously working container build now require this. I was getting this error before this fix:

W: GPG error: http://deb.nodesource.com trusty InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1655A0AB68576280
W: GPG error: http://archive.ubuntu.com trusty-updates InRelease: 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-backports InRelease: 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 InRelease: 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

protected by Community Sep 30 '14 at 11:58

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.