Bizzard's Hackshop
Always under construction!

Fix for NO_PUBKEY error in apt-get when using third party repositories

Being a Debian user, I always like to experiment with the latest packages, and so I have many third party debian repositories listed in the sources.list file. Whenever I am adding it for the first time, I usually get the error:

“The following signatures couldn’t be verified because the public key is not available”

On googling multiple solutions can be found to add a public key using apt-key, but most of them has 3 or 4 commands, including downloading the key, move it to a file and then import. But the one line command that does the same is as below:

apt-key adv --keyserver keyserver_url --recv-keys key_id

This works only if the public key is listed in the key server specified at keyserver_url and for me, most of the time, it works. Few commonly used keyservers are below:


The key_id is the identifier for the key, which can be received from the error provided by apt-get update command. For example, when I add the google chrome repo in sources.list, I get the following error:

W: GPG error: stable Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY A040830F7FAC5991

So, substitute A040830F7FAC5991 for key_id and the command will look as below:

apt-key adv --keyserver --recv-keys A040830F7FAC5991

The successful output is as below:

Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /tmp/tmp.3rFiT8JN1B –trustdb-name /etc/apt//trustdb.gpg –keyring /etc/apt/trusted.gpg –primary-keyring /etc/apt/trusted.gpg –keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-automatic.gpg –keyring /etc/apt/trusted.gpg.d//debian-archive-squeeze-stable.gpg –keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-automatic.gpg –keyring /etc/apt/trusted.gpg.d//debian-archive-wheezy-stable.gpg –keyserver –recv-keys A040830F7FAC5991
gpg: requesting key 7FAC5991 from hkp server
gpg: key 7FAC5991: public key “Google, Inc. Linux Package Signing Key <>” imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1

Tagged with: , , , , ,

Leave a Reply