I have just installed Ubuntu 12.04 and I added some repo, and when I did apt-get update , I got missing gpg key.

The following command seems to not work for me

apt-get update 2> /tmp/keymissing; for key in $(grep "NO_PUBKEY" /tmp/keymissing |sed "s/.*NO_PUBKEY //"); do echo -e "\nProcessing key: $key"; gpg --keyserver subkeys.pgp.net --recv $key && sudo gpg --export --armor $key | apt-key add -; done

What's the best way to fix this problem?

Best Answer


I liked this solution, re-download the missing keys from the ubuntu key server.

For Ubuntu

In my case

 Reading package lists... Done
 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 2EA8F35793D8809A

Here's the command to add the missing key mentioned in the error message

sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 2EA8F35793D8809A

So I take the missing key 2EA8F35793D8809A and ask the keyserver.ubuntu.com to added it to the list of keys I have in apt.

For linux mint
Your key server is slightly different keyserver.linuxmint.com

sudo apt-key adv --recv-key --keyserver keyserver.linuxmint.com "missing key"

Alternative key servers to try
keyserver.ubuntu.com