105

I ran this command in the Terminal:

sudo apt-get update

Updating ends with the following error report:

W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://extras.ubuntu.com precise Release: The following signatures were invalid: BADSIG 16126D3A3E5C1192 Ubuntu Extras Archive Automatic Signing Key <ftpmaster@ubuntu.com>

W: GPG error: http://ppa.launchpad.net precise Release: The following signatures were invalid: BADSIG 4C1CBC1B69B0E2F4 Launchpad PPA for Jonathan French
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/precise/Release  

What does this mean and why is it happening?

  • 4
    I saw similar issue when I first installed the 12.04. After that I changed the "Software Sources" from the software manager from India to another server. Now I am not seeing this issue. If you are using India server, change it and let us know. – Abhijeet May 4 '12 at 18:11
  • Thanx Abhijeet. I am an Indian but staying here in Qatar.I changed server to Saudi Arabia.But same result. – beeju May 4 '12 at 18:19
  • For myself, I had a PPA in /etc/apt/sources.list.d/ that no longer existed and so this error was coming up. I had to remove that (actually, replace it with an updated repo for ffmpeg that I needed) and then sudo apt-get update worked just fine. – Joshua Pinter Jun 23 at 15:23

11 Answers 11

100

Try this:

sudo apt-get clean
sudo mv /var/lib/apt/lists /tmp
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get update
| improve this answer | |
  • 5
    No need to create the partial subdirectory. sudo apt-get update will do that itself. – Byte Commander Feb 15 '16 at 8:46
  • 12
    after doing the above I still get this error: Reading package lists... Done W: GPG error: http://developer.download.nvidia.com Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F60F4B3D7FA2AF80 – Mona Jalal Sep 29 '16 at 20:48
  • It might be worth answering the question asked (and earning more upvotes ;-) ). – Witold Kaczurba Aug 19 '18 at 12:22
  • error encountered on second step: mv: cannot move '/var/lib/apt/lists' to '/tmp/lists': Directory not empty – Internet User May 10 '19 at 21:36
  • Could you elaborate what this exactly does? Thank you, – Hendrik Sep 3 '19 at 10:33
72

This message is displaying because the gpg key for that repository is missing in your apt-key database.

To import the key, open a terminal and enter these commands

gpg --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192 

pgp keys are mostly distributed in several keystore. Ubuntu related keys are usually found in keyserver.ubuntu.com. But if that fails you can use alternatives. Like -

gpg --keyserver hkp://subkeys.pgp.net --recv-keys 16126D3A3E5C1192

You must replace the alphanumeric part, with the specific key. Make sure the key is one you trust. Any repository with this key, would be able to install any package without warning.

You would see the following output if the above is successful

gpg: Total number processed: 1
gpg:               imported: 1

Then run this command:

gpg --export --armor 16126D3A3E5C1192 | sudo apt-key add - 

Note the - sign after add.

Then sudo apt-get update, you will have no such messages after this.

| improve this answer | |
  • 1
    Hi@anwar where/how do i get the key that i trust? – soMuchToLearn Oct 29 '18 at 14:30
  • 1
    @MinnieShi The key is present in the error message itself The following signatures were invalid: BADSIG 16126D3A3E5C1192 – Kalyan Raghu May 6 '19 at 17:35
  • 1
    Note that the apt-key add command should return "OK". – COil Jun 1 '19 at 9:48
  • Great, should be the accepted answer! Thanks. – Jacob Aug 19 '19 at 10:17
  • I get this after the gpg --export, and it still fails with apt, any advice pls?: gpg: WARNING: unsafe ownership on homedir '/home/abc/.gnupg'; OK – alchemy Mar 12 at 22:47
14

I found that just doing

sudo rm -rf /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists

worked for me.

| improve this answer | |
  • Use sudo rm -rf /var/lib/apt/lists/* && sudo mkdir -p /var/lib/apt/lists to preserve whatever /var/lib/apt/lists permission might have – 131 Nov 13 '15 at 16:22
  • 1
    No need to create the partial subdirectory. sudo apt-get update will do that itself. – Byte Commander Feb 15 '16 at 8:53
  • -1 Ignores the fact that lists needs to be owned by _apt, so creates a new issue where you get a W: Download is performed unsandboxed as root as file... error when you update. – Elliptical view Jan 25 at 1:08
12

You can try my script to automatically receive all GPG keys for PPAs you use: smartupdate.sh.

It will launch apt-get update, then find all GPG errors and receive keys for found GPG signatures. In your case, it will just launch

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4C1CBC1B69B0E2F4

but when you add a few unsigned PPAs, it becomes boring to add GPG keys manually. :)

| improve this answer | |
5

The following commands solved the problem for me:

sudo -i
apt-get clean
cd /var/lib/apt
mv lists lists.old
mkdir -p lists/partial
apt-get clean
apt-get update
| improve this answer | |
  • 1
    No need to create the partial subdirectory. sudo apt-get update will do that itself. – Byte Commander Feb 15 '16 at 8:53
  • -1 destroy's lists ownership. Same for partial. – Elliptical view Jan 25 at 1:07
4

I got a similar error. But instead of BADSIG I got KEYEXPIRED for the PostgreSQL repo:

W: A error occurred during the signature verification.
  The repository is not updated and the previous index files will be used.
  GPG error: http://apt.postgresql.org precise-pgdg Release:
  The following signatures were invalid: KEYEXPIRED 1381654177

The solution is perfectly described here but this is what I did to solve it:

$ sudo apt-key list | grep -B1 PostgreSQL
$ sudo apt-key del ACCC4CF8
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

And now $ sudo apt-get update will work perfectly!

| improve this answer | |
1

This tip (from actionparsnip) worked for me:

Try:

sudo fuser -vvv /var/lib/dpkg/lock
sudo rm /var/lib/apt/lists/lock
sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists
sudo rm /var/cache/apt/*.bin
sudo mkdir /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists/partial
LANG=C;sudo apt-get clean
LANG=C;sudo apt-get autoclean
LANG=C;sudo apt-get --purge autoremove
LANG=C;sudo apt-get update -o APT::Cache-Limit=25165824
sudo dpkg --clear-avail
sudo dpkg --configure -a
LANG=C;sudo apt-get -f install
LANG=C;sudo apt-get --fix-missing install
LANG=C;sudo apt-get update -o APT::Cache-Limit=25165824 && sudo apt-get dist-upgrade

Found in:
https://answers.launchpad.net/ubuntu/+source/update-manager/+question/194077

| improve this answer | |
1

This could be due to a caching issue of a HTTP proxy. If you have one of those somewhere along the route like me, you can ask Apt to ask it to circumvent the cache temporarily:

sudo apt-get update -o Acquire::http::No-Cache=True
| improve this answer | |
0

DON'T DO THIS (the accepted answer here):

sudo apt-get clean
sudo mv /var/lib/apt/lists /tmp
sudo mkdir -p /var/lib/apt/lists/partial
sudo apt-get clean
sudo apt-get update

Because it creates a new problem, in the process of fixing your problem.

You need to preserve the existing ownership and permissions of the lists folder.


So instead, as 131 suggests in a comment above, do it this way:

# -- First clean things up
sudo apt-get clean
sudo cp -a /var/lib/apt/lists /tmp          # optional step to save a backup
sudo rm -r /var/lib/apt/lists/*             # preserves `lists` ownership!

# -- Then rebuild the package list
# sudo mkdir -p /var/lib/apt/lists/partial  # You don't need this step.
                                            #   apt update does it for you
# sudo apt-get clean                        # or this step
sudo apt update                             # This does the rebuild

tl;dr

sudo rm -r /var/lib/apt/lists/*
sudo apt update 
| improve this answer | |
0

I ran into this issue an older Ubuntu 16.04 box. My keys weren't expired so I wasn't really sure why I was getting the error. I tried SirCharlo's method but I still got the same errors. Being this particular error is coming from the 'Ubuntu Extras Archive Automatic Signing Key' I decided to refresh my keys. After doing that everything worked fine. Not sure if it was a combination of both method's but if SirCharlo's method doesn't work, run this command:

apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
| improve this answer | |
-2

You can use launchpad-getkeys to fix this. Open a terminal and enter:

sudo apt-get install launchpad-getkeys
sudo launchpad-getkeys

Then

sudo apt-get update
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.