受欢迎的博客标签

Ubuntu Error Series: Fix apt-get update “the following signatures couldn’t be verified because the public key is not available”

Published

There are times when running apt-get update in Ubuntu will result in error messages such as the following:

root@vultr:~# sudo apt update
Hit:1 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease                                                           
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                        
Get:4 https://packages.microsoft.com/ubuntu/22.04/prod jammy InRelease [3,065 B]                                 
Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]                                          
Get:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Err:4 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
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2,461 kB]                                                                                                                                                
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1,713 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/restricted i386 Packages [30.5 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [720 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,045 kB]
Error: Timeout was reached                                 
Reading package lists... Done
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
E: The repository 'https://packages.microsoft.com/ubuntu/22.04/prod jammy 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.

If these errors aren’t fixed, apt will have problems when installing or upgrading packages.

The apt packaging system has a set of trusted keys that determine whether a package can be authenticated and therefore trusted to be installed on the system. Sometimes the system does not have all the keys it needs and runs into this issue. Fortunately, there is a quick fix. Each key that is listed as missing needs to be added to the apt key manager so that it can authenticate the packages.

Looking at the error above, apt is telling us that the following keys are missing:  EB3E94ADBE1229CF. Notice that these are listed multiple times. Each unique key will only need to be added once.

Solution

To add these keys, run the following commands:

root@vultr:~# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EB3E94ADBE1229CF
Executing: /tmp/apt-key-gpghome.rEHijVlTON/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys EB3E94ADBE1229CF
gpg: key EB3E94ADBE1229CF: "Microsoft (Release signing) <[email protected]>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

If the keys that your system is missing differs, simply replace the key at the end of the above command with your key and run it.