Fix: apt-get – there is no public key available

PowerADM.com / Linux / Debian / Fix: apt-get – there is no public key available

An error may occur when updating the apt deb package manager cache on Linux (Ubuntu or Debian distros):

$ apt-get update

W: There is no public key available for the following key IDs: 467B942D3A79BD29
W: GPG error: https://repo.mysql.com/apt/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29

apt-get - there is no public key available

The most common time this happens is after a new repository has been added to the /etc/apt/sources.list.

This error indicates that your Linux computer doesn’t have a public GnuPG repository key from which you are trying to install the package. The key hash is displayed directly in the error message. It is shown in this example: NO_PUBKEY 467B942D3A79BD29.

You must add this key to the apt database.

On Ubuntu, you can download the key from the key server (specify the key hash in the following command):

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29

apt-key add key from ubuntu keyserver

This is a key for MySQL, as seen in this example.

List the keys and check that a new key has been added:

$ apt-key list

apt-key list

On Debian, you can install a package with all the keys used to sign all the Release files:

$ apt-get install debian-archive-keyring

In my case, I got an error when trying to install the SQL Server package on Ubuntu:

The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
W: GPG error: https://packages.microsoft.com/ubuntu/22.04/prod jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF

To install the Microsoft GPG keys, run the command:

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
Leave a Reply

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