Fix software sources bad behaviour


Every now and then you will run into the problem of not having the correct keys for the software sources that you enter into Synaptic. A lot of the time, this is because nobody bothered to give them to you, or you just haven’t figured out how to request them using gpg.
This is what the error looks like:

W: GPG error: hardy Release:
The following signatures couldn't be verified because the public key
is not available: NO_PUBKEY EF4186FE247510B

Fixing this is simple. Open a terminal and replace the word KEY in both lines with the key you want to get (for example, EF4186FE247510BE). Do this for each key.

gpg --keyserver hkp:// --recv-keys KEY
gpg --export --armor KEY | sudo apt-key add -


sudo apt-get update

Works like magic. Thank you to Michy99 from Ubuntu Forums for pointing this out. I also found a method for querying keyservers and adding keys from the index the long way. The tutorial is at RebelZero.Com and it is probably more security conscious than the above method.
UPDATE: I found a one line method for rectifying the problem. A lot faster than either of the above methods.
Allaun recommends using the NO_PUBKEY value (e.g. C5E6A5ED249AD24C) to add the key with the following command.

sudo apt-key adv --recv-keys --keyserver C5E6A5ED249AD24C

Categories: CLI Ubuntu

2 Replies to “Fix software sources bad behaviour”

Leave a Reply

Your email address will not be published. Required fields are marked *