How do I fix "no public keys available" errors? [duplicate]

When I download updates or installing new software I get these warnings that I have no public keys. This just appeared one day and I didn't remove/add something to create this.

Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

I have tried: sudo apt-key update and it worked for some keys, but others are still missing, I need to add them.

I need help with adding the new keys and the address to all the keys. Those that aren't in Ubuntu and launchpad.


Solution 1:

Getting the Keys, Part 1

The program addgpg-apt - which is mine - will only work if the keys are on the Ubuntu keyserver, unless you specifically specify what key server you are trying to get the key from. It does not go out to the internet and find what key server the PGP key is on.

Using the following command:

sudo apt-get update | grep "NO_PUBKEY" | awk '{ system("addgpg-apt "$21) }'

Will systematically go through each line of output and send each key to addgpg-apt program. addgpg-apt will attempt to get the key from the Ubuntu keyservers.

For ubuntu.com or launchpad.net items, it will work without issue. For keys for other GPG Keyservers, you'll need to find the locations of those keys in their respective keyserver, then use addgpg-apt with the --keyserver flag for each:

addgpg-apt --keyserver <keyserver> <keyid>

That will then take the keys and place them into your APT keyring.

The addgpg-apt program is available via PPA

  • What are PPAs and how do you use them?

If the first command fails, try this one:

sudo apt-get update | grep "NO_PUBKEY" | awk '{ print $21) }' | xargs addgpg-apt

This will perform the same action as above, only operates differently.

Getting the Keys, Part 2

I recommend checking the site(s) for the other non-Ubuntu and non-Launchpad repositories for the PGP keys, as they more than likely are listed there. After you find each one, you can run addgpg-apt --keyserver <keyserver> <keyid> and it will download from those repositories' key servers.