Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB GPG - Invalid Signatures

Tags:

mongodb

ubuntu

I'm installing MongoDB on an Ubuntu 14.04 machine, using the instructions at: https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

So I run:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

And then:

echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

Followed by:

sudo apt-get update

I then get the following warning at the end of the update:

W: GPG error: http://repo.mongodb.org trusty/mongodb-org/3.2 Release: The following signatures were invalid: BADSIG D68FA50FEA312927 MongoDB 3.2 Release Signing Key

If I ignore the warning and try to run:

sudo apt-get install -y mongodb-org

I get:

WARNING: The following packages cannot be authenticated!
mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools mongodb-org E: There are problems and -y was used without --force-yes

Any ideas on how to resolve? Thanks!

like image 217
Assaf Hershko Avatar asked Jan 11 '16 23:01

Assaf Hershko


3 Answers

Update all expired keys from Ubuntu key server in one command:

sudo apt-key list | \
 grep "expired: " | \
 sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' | \
 xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys

Command explanation:

  1. sudo apt-key list - lists all keys installed in the system;
  2. grep "expired: " - leave only lines with expired keys;
  3. sed -ne 's|pub .*/\([^ ]*\) .*|\1|gp' - extracts keys;
  4. xargs -n1 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys - updates keys from Ubuntu key server by found expired ones.

Source

like image 150
dlopatin Avatar answered Nov 03 '22 02:11

dlopatin


Sounds like you need to redo the installation steps for MongoDB. First, remove any existing repository file for MongoDB. Do as below:

$ sudo rm /etc/apt/sources.list.d/mongodb*.list

Next, add the key (without the key, the repository will not load):

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

Now, create a new MongoDB repository list file:

$ echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

After adding the repository details, we need to update the packages list:

$ sudo apt-get update

Now install MongoDB:

sudo apt install mongodb-org
like image 53
PyDevSRS Avatar answered Nov 03 '22 02:11

PyDevSRS


You don't need to reinstall the mongo packages, but just change the key as following:

List the keys to confirm it is expired:

apt-key list | grep "expired:"

Replace the key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xd68fa50fea312927

The number 0xd68fa50fea312927 is the current valid key id (expires at 2019-10-09), as you can check here.

like image 27
Juliano ENS Avatar answered Nov 03 '22 04:11

Juliano ENS