How to successfully implement sudo apt-get update after key import fails

How to successfully implement sudo apt-get update after key import failure

  • briefing
    • Solution

Situation Brief

After changing the source, I used sudo apt-get update and found that reported that the following signature could not be verified because there is no public key: NO_PUBKEY error. After consulting a lot of information, , all are imported keys using sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys. After the import is successful, you can use sudo apt-get update has been updated, but my problem is that the key cannot be imported, and the following error will appear.

Executing: /tmp/apt-key-gpghome.kl8yx674H2/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys xxxxxxxx
gpg: Key xxxxxxxxxx: "Valve Corporation <[email protected]>" unchanged
gpg: Total number of processes: 1
gpg: unchanged: 1

After searching for information many times and almost breaking the defense, I finally solved this problem today, so I wanted to write about this problem so that others can solve it in one go, without having to open dozens of pages like me.

Solution

Solve it based on the error reported when we use sudo apt-get update
For example, my error message is

Get:1 file:/var/cudnn-local-repo-ubuntu2004-8.8.0.121 InRelease [1,572 B]
Get: 1 file:/var/cudnn-local-repo-ubuntu2004-8.8.0.121 InRelease [1,572 B]
Hits: 2 http://mirrors.aliyun.com/docker-ce/linux/ubuntu focal InRelease
Hits: 3 https://dl.google.com/linux/chrome/deb stable InRelease
Hits: 4 http://packages.microsoft.com/repos/code stable InRelease
Hits: 6 https://download.docker.com/linux/ubuntu focal InRelease
Hits: 5 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-updates InRelease
Hits: 7 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hits: 8 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal InRelease
Hits: 9 https://packages.microsoft.com/repos/edge stable InRelease
Hits: 10 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hits: 11 http://security.ubuntu.com/ubuntu focal-security InRelease
Hits: 12 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease
Hits: 13 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hits: 14 http://mirrors.tuna.tsinghua.edu.cn/ubuntu focal-backports InRelease
Get: 15 https://repo.steampowered.com/steam stable InRelease [2,861 B]
Hits: 16 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Error:15 https://repo.steampowered.com/steam stable InRelease
  The following signature cannot be verified because there is no public key: NO_PUBKEY F24AEA9FB05498B7
Ignore:17 https://repo.nordvpn.com/deb/nordvpn/debian stable InRelease
Error:18 http://typora.io linux/ InRelease
  Connection failed [IP: 198.18.0.58 80]
Error: 19 https://repo.nordvpn.com/deb/nordvpn/debian stable Release
  Could not handshake: Error in the pull function. [IP: 198.18.0.18 443]
Reading package list... Done
W: GPG Error: https://repo.steampowered.com/steam stable InRelease: The following signature cannot be verified because there is no public key: NO_PUBKEY F24AEA9FB05498B7
E: The repository "https://repo.steampowered.com/steam stable InRelease" does not have a digital signature.
N: This source cannot be safely used for updates, so it is disabled by default.
N: See the apt-secure(8) manual for details on repository creation and user configuration.
E: The repository "https://repo.nordvpn.com/deb/nordvpn/debian stable Release" no longer contains Release files.
N: This source cannot be safely used for updates, so it is disabled by default.
N: See the apt-secure(8) manual for details on repository creation and user configuration.

It can be found that our error without public key appears on https://repo.steampowered.com/steam stable InRelease, then we can find this URL on source.list and comment it out
If there is no such URL in your source.list, then execute

cd /etc/apt/sources.list.d/

Then use ls to find the files related to this.
such as mine

You can see steam-stable.list, then we can comment out the results.
Finally, you can update successfully.
! ! ! !