Ask Your Question

apt update fails / cannot install pkgs: key not working?

asked 2019-06-08 02:12:04 -0600

gvdhoorn gravatar image

updated 2019-09-05 06:09:58 -0600

When trying to install packages, I'm seeing errors similar to the following:

Err:1 <YOUR_UBUNTU_VERSION>/main amd64 <SOME_ROS_PKG> amd64 0.13.3-0xenial-20190320-132757-0800
  404  Not Found [IP: 80]

While running sudo apt update I see the following error:

W: GPG error: <YOUR_UBUNTU_VERSION> InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5523BAEEB01FA116

and or:

W: Failed to fetch<YOUR_UBUNTU_VERSION>/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654
W: Some index files failed to download. They have been ignored, or old ones used instead.

While running sudo apt install I see the following error:

WARNING: The following packages cannot be authenticated! <some_pkgs>

and also sometimes (just an example, could be any package or ROS version):

E: Failed to fetch  404  Not Found [IP: 80]

This completely prevents me from installing ROS (and related) packages.

edit retag flag offensive close merge delete


Related: #q324350.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-08 02:26:45 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2019-06-08 02:22:14 -0600

gvdhoorn gravatar image

updated 2019-10-02 04:57:42 -0600


The old key has been revoked as part of the measures to deal with a recent security incident with (Security issue on ROS build farm).

The key has been updated and the old one is no longer valid, causing the issues with apt update and apt install.

The keys have also changed for the ROS 2 repositories, see: Key rotation for ROS 2 apt repositories.


  • old key: 421C365BD9FF1F717815A3895523BAEEB01FA116
  • new key: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654


Refer to New GPG keys deployed for for the full write-up, but as a summary these are the commands for Ubuntu (and Debian):

Remove the old key

  • on Ubuntu 16.04 and newer (with ROS Kinetic, Melodic, etc):

    sudo apt-key del 421C365BD9FF1F717815A3895523BAEEB01FA116
  • on Ubuntu 15.10 and older (ie: 14.04, from here):

    sudo apt-key del B01FA116

Import the new key

This command should work on all versions of Ubuntu:

# add the new key
sudo -E apt-key adv --keyserver 'hkp://' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

Final step

At this point make sure to run sudo apt clean && sudo apt update. You should receive no errors and subsequent sudo apt install commands should also now work.

Additional notes

Installation tutorials are in the process of being updated, so if you're following one and you are seeing key-related errors, check that the tutorial is using the correct key.

If it isn't, notify the author or maintainer of the tutorial or website so it can be updated.

edit flag offensive delete link more


this helped me. Thanks a lot.

AlexR gravatar image AlexR  ( 2019-06-10 04:58:47 -0600 )edit

Thank you! A little addition: Add the "-E" option to sudo in order to use environment variables in case you are trying to connect from beyond a firewall. (This requires to set the proxy variables for apt e.g. in "/etc/apt/conf.d".)

sudo -E  apt-key adv --keyserver 'hkp://' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

See also:

Zacryon gravatar image Zacryon  ( 2019-06-11 03:28:17 -0600 )edit

@Zacryon: I feel it's rather specific to your setup, but I've updated the answer.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-11 03:31:44 -0600 )edit

This worked for me as well, thanks a lot.

Radeshwar gravatar image Radeshwar  ( 2019-06-19 04:57:36 -0600 )edit

Its work for Melodic as well

cesarhcq gravatar image cesarhcq  ( 2019-06-20 18:25:18 -0600 )edit

Thanks! works :D (Ubuntu 18.04, melodic)

Oscar Lima gravatar image Oscar Lima  ( 2019-06-24 08:20:52 -0600 )edit

I tried this and it solved the issue with the key, but I still get:

Get:29 xenial/main amd64 Packages [3.150 kB] Err:29 xenial/main amd64 Packages Writing more data than expected (3151533 > 3149706) [IP: 80]

anyone else experiencing this?

matteolucchi gravatar image matteolucchi  ( 2019-07-24 10:46:25 -0600 )edit

Did you try to execute "sudo apt-get update" again? After modification of the key.

cesarhcq gravatar image cesarhcq  ( 2019-07-24 11:00:50 -0600 )edit

answered 2019-06-19 05:55:50 -0600

nickzherdev gravatar image

That didn't work for me.

This command did:

sudo launchpad-getkeys
edit flag offensive delete link more



Can you clarify what "didn't work for me" means exactly?

It didn't import the correct key? It couldn't reach the key server? Something else?

gvdhoorn gravatar image gvdhoorn  ( 2019-06-19 06:47:44 -0600 )edit

Thanks, this answer is work for me.

nunuwin gravatar image nunuwin  ( 2019-06-22 01:12:30 -0600 )edit

Thanks. it worked

rayane gravatar image rayane  ( 2019-07-10 03:21:38 -0600 )edit

Thank you, it was very helpful. Regards

mecb1407 gravatar image mecb1407  ( 2019-09-28 16:18:48 -0600 )edit

answered 2020-07-06 01:51:31 -0600

parzival gravatar image

gvdhoorn has a fantastic answer. I'd just like to point to solution to a problem which can be caused on remote machines like a Raspberry Pi. I had renewed the keys and was surprised as I still received the error.

I checked the expiry date using the command sudo apt-key list | grep -A 1 expired and found that the key wasn't expired yet, still it showed as expired.

I later found the time of my system (Raspberry Pi) was wrong and showed year 2024.

A simple sync via internet (using a command like sudo ntpdate fixed the date, and then the apt update and apt install commands ran perfectly!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-06-08 02:12:04 -0600

Seen: 69,559 times

Last updated: Jul 06 '20