How Do You Troubleshoot an apt Command That Has an Error “An error occurred during the signature verification”?

Problem scenario
You are trying to run an apt command. It is failing. You get an error like this:

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mongodb.org/apt/ubuntu…/foobar/1.1 Release: The following signatures were invalid: KEYEXPIRED 1507497109

What should you do?

Possible solution #1
This is not recommended. If for some reason you are not concerned about security on the server, try one or both of these commands:

sudo apt-get update --allow-unauthenticated
sudo apt-get update --allow-insecure-repositories

You may want to read this posting.

Possible solution #2
Find sources.list: sudo find / -name sources.list

If the file has references to foobar (where "foobar" is the repository name in the error), back up sources.list, edit sources.list so there are no references too it. Run sudo apt -y update, and try your apt command again.

Possible solution #3
Go to /etc/apt/sources.list.d/
Find files that refer to the "foobar" in the error. Back them up to files like this:
bak.original.name.bak. Now run the sudo apt -y update command. Now try your apt command again.

Possible solution #4
If the error is like this "W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com/apt cloud-sdk-buster InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY ABC1234567DEF890 NO_PUBKEY DEC9876GFE999

Run these commands*:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABC1234567DEF890
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DEC9876GFE999

*Replace "ABC1234567DEF890" or "DEC9876GFE999" with the hexadecimal string you see. You may only have to run the command one time.

Leave a comment

Your email address will not be published. Required fields are marked *