APT: How to fix the NO_PUBKEY warning message

The reason

The following is a very common error message that haunts all Debian-like system administrators:

$ sudo apt-get update

W: GPG error: http://opensource.wandisco.com squeeze Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY E9F0E9223BBF077A

If you’re getting that error message it is because one of the APT repositories you’re using (probably configured in the @/etc/apt/sources.list@ file) cannot be authenticated. The authentication of each APT respository is done using the GPG/PGP system and the public keys of that server are not in your local APT database.

The solution for the NO_PUBKEY warning

Ok, but how do I fix it? There are a dozen ways to store the key in APT’s database, but the fastest and probably the easiest way is to run the following oneliner:

$ sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys E9F0E9223BBF077A
Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /etc/apt/secring.gpg –trustdb-name /etc/apt/trustdb.gpg –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyserver keyserver.ubuntu.com –recv-keys E9F0E9223BBF077A
gpg: requesting key 3BBF077A from hkp server keyserver.ubuntu.com
gpg: key 3BBF077A: public key “WANdisco (http://WANdisco.com – We Make Software Happen…) ” imported
gpg: Total number processed: 1
gpg: imported: 1

And… wham! You’re good to run apt-get update again. Oh, of course you have to change that horrible last word with the public key “code” (usually following the NO_PUBKEY keyword on the APT error message) of your APT repository. If you have multiple keys to be added just append them to the command:

$ sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys E9F0E9223BBF077A \
A040830F7FAC5991 54422A4B98AB5139 8B48AD6246925553 16126D3A3E5C1192 \
83FBA1751378B444 B5B7720097BB3B58

$ sudo apt-get update

I hope this helps ya. 😉