Blog

Fixing Ubuntu's GPG error issue

Fixing Ubuntu's GPG error issue

Copyright © TechPad.co.uk

For weeks my Ubuntu Karmic Koala workstation has been plagued by an apt error telling me that my public keys were not available...

It seems I have not been alone in experiencing some bad Karma with the otherwise excellent Ubuntu Karmic Koala 9.10. For the past few weeks, since fiddling with my sources.list, I've been getting some annoying messages when I run sudo apt-get update. 

At first, I tried removing the offending servers from my sources.list, but I still received the error. 

W: GPG error: http://archive.canonical.com karmic Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
W: GPG error: http://gb.archive.ubuntu.com karmic Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
W: GPG error: http://gb.archive.ubuntu.com karmic-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
W: GPG error: http://gb.archive.ubuntu.com karmic-security Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5

Adding the missing keys
Following some advice from the Ubuntu Forums, I realised that what I needed to do what to update the list of keys held locally and get the missing keys added. 

For each key, I tried running the following command: gpg --keyserver keyserver.ubuntu.com --recv 40976EAF437D05B5 (where 40976EAF437D05B5 was the offending key). However, when I re-ran sudo apt-get update, I still got the same errors. 

A closer look, revealed that the lengthy "key" lists in my error messages were actually different to those I was seeing in the successful commands used by others in the Linux community. Their keys all started with 437 and were much shorter - so I tried chopping a chunk off the beginning of the string to produce a command like: gpg --keyserver keyserver.ubuntu.com --recv 437D05B5

And then ran this: gpg --keyserver keyserver.ubuntu.com --recv 437D05B5; gpg --export --armor 437D05B5 | sudo apt-key add -; gpg --keyserver keyserver.ubuntu.com --recv 437D05B5; gpg --export --armor 437D05B5 | sudo apt-key add -; sudo apt-get update

Unfortunately, that didn't seem to do anything either...

Invalid packet...
Trying the following commands also gives me a nasty looking error: 

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5

matt@q9550:/etc/apt$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys
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 --keyserver keyserver.ubuntu.com --recv-keys
matt@q9550:/etc/apt$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
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 --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: [don't know]: invalid packet (ctb=23)
gpg: keydb_get_keyblock failed: eof
gpg: [don't know]: invalid packet (ctb=23)
gpg: /etc/apt/trusted.gpg: copy to `/etc/apt/trusted.gpg.tmp' failed: invalid packet
gpg: error writing keyring `/etc/apt/trusted.gpg': invalid packet
gpg: [don't know]: invalid packet (ctb=23)
gpg: keydb_search failed: invalid packet
gpg: key 437D05B5: public key "[User ID not found]" imported
gpg: error reading `[stream]': invalid packet
gpg: Total number processed: 0
gpg:               imported: 1
matt@q9550:/etc/apt$ 

The solution
After a bit of head scratching, it seems the simple solution is to delete all of the GPG keys in /etc/apt and re-run apt-get update.

cd /etc/apt
sudo rm *.gpg
gpg --export -a 437D05B5 | sudo apt-key add -
sudo apt-get update

Bingo! It works. No errors. 


Published: TechPad.co.uk Sunday 27 December 2009, 3:39 pm
Views: 17,773 times
Filed under: Ubuntu apt bug GPG

(No votes yet)



Login to leave your comments

Please login

Username
Password
  Remember me
Reset password | Send activation code

Related items

MSI launches Wind U100 UMPC
MSI launches Wind U100 UMPC
MSI has launched its competitor to the ube... 5 (1 vote)
Dell Mini Inspiron to be called Dell E
Dell Mini Inspiron to be called Dell E
The sleek-looking netbook dubbed the Mini ... no votes (No votes)
How to install Ubuntu Netbook Remix on the Asus Eee PC
How to install Ubuntu Netbook Remix on the Asus Eee PC
Get a taste of the forthcoming Ubuntu Netb... 5 (1 vote)
How to install software on Ubuntu Linux
How to install software on Ubuntu Linux
Ubuntu is one of the easiest Linux distrib... 5 (1 vote)
How to keep your Ubuntu Linux system up to date
How to keep your Ubuntu Linux system up to date
Ubuntu makes it really easy to keep your s... no votes (No votes)

Recently added

How to create a Linux iPlayer download GUI using Zenity
How to create a Linux iPlayer download GUI using Zenity
Here's how I created a simple graphical ut... no votes (No votes)
A taste of iPhone support coming in Ubuntu Lucid Lynx
A taste of iPhone support coming in Ubuntu Lucid Lynx
Ubuntu's Lucid Lynx release, which comes o... no votes (No votes)
Frequently asked questions on NexentaCore
Frequently asked questions on NexentaCore
Frequently asked questions about NexentaCo... no votes (No votes)
Create a video transcoder GUI with Zenity and ffmpeg
Create a video transcoder GUI with Zenity and ffmpeg
Create a GUI application for your Linux co... 4 (1 vote)

Most viewed


Recent comments


Analytics sites

Web Analytics Demystified
Web Analytics Demystified
Eric T. Peterson is the fou...
Excellent Analytics free Excel plugin
Excellent Analytics free Excel plugin
Excellent Analytics is a si...
Visual Revenue blog
Visual Revenue blog
Interesting web analytics, ...