I am trying to install ROS2 on Ubuntu 18.04.
The following command gives an error for not having the public key.
sudo apt update && sudo apt install curl gnupg2 lsb-release
Error:
Hit:1 http://ppa.launchpad.net/webupd8team/y-ppa-manager/ubuntu bionic InRelease
Hit:2 http://de.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://de.archive.ubuntu.com/ubuntu bionic-updates InRelease
Get:4 http://de.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://packages.ros.org/ros2/ubuntu bionic InRelease [2,565 B]
Err:6 http://packages.ros.org/ros2/ubuntu bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5523BAEEB01FA116
Reading package lists... Done
W: GPG error: http://packages.ros.org/ros2/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5523BAEEB01FA116
E: The repository 'http://packages.ros.org/ros2/ubuntu bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
I tried following ways to get the key:
sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 5523BAEEB01FA116
and
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5523BAEEB01FA116
and y-ppa-manager ("Try to import all missing GPG keys")
sudo add-apt-repository ppa:webupd8team/y-ppa-manager
sudo apt-get install y-ppa-manager
y-ppa-manager
all the above methods give the following error
gpg: keyserver receive failed: No keyserver available
I am running Ubuntu 18.04 using a VM on a Windows 7 host.
How to avail the keyserver?
You can get a copy of the currently working key from the Dockerfile used for the nightly build of the osrf/ros2 Docker image: https://hub.docker.com/r/osrf/ros2/dockerfile
It's not a future-proof solution though, because I was initially using a different key for ROS2 Crystal, and then that key suddenly stopped working (we also have our own regular builds) and I got the same error as you. It turns out I had to update our build with the new keys.
I think a better solution moving forward is to just use that pre-built ROS2 environment available as a Docker image. That way, the keys get updated when they update it.