注意:每一台机器出现的公钥可能不同,你只需要替换公钥就行了。
一、问题概述
(base) root@OVO:/# apt update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [128 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [128 kB]
Get:4 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease [1581 B]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [128 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [4144 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1568 kB]
Err:4 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [34.6 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [4348 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [4596 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [1279 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [4112 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [30.9 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [28.6 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [55.2 kB]
Reading package lists... Done
W: GPG error: https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC
E: The repository 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 InRelease' is no longer 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.
二、解决方法
这个问题是由于你的系统缺少 NVIDIA CUDA 仓库的 GPG 公钥,导致无法验证其签名。为了解决这个问题,你需要手动下载并导入缺失的 GPG 公钥。可以按照以下步骤进行操作:
- 获取缺失的 GPG 公钥 :
错误信息中指出缺少的公钥是A4B469963BF863CC
。你可以通过以下命令下载并导入这个公钥:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A4B469963BF863CC
这条命令会从 Ubuntu 的公钥服务器下载并导入缺失的公钥。
- 更新软件包列表 :
公钥导入后,执行以下命令更新软件包列表:
sudo apt update
如果一切顺利,问题应该得到解决,且你能顺利完成更新。
-
如果上述方法失败,尝试以下步骤 :
如果仍然无法解决,尝试手动下载 NVIDIA 公钥并添加到系统中。你可以通过以下步骤操作:- 下载 NVIDIA CUDA 的公钥:
wget https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
- 将公钥添加到系统:
sudo apt-key add 7fa2af80.pub
- 最后,再次更新软件包列表:
sudo apt update
完美解决问题:
- 移除有问题的 CUDA 仓库(如果不需要) :
如果你不再使用 NVIDIA CUDA,可以从/etc/apt/sources.list.d/
中删除相关的 CUDA 仓库配置文件,或者禁用该仓库。
查找并删除(或注释)包含developer.download.nvidia.com
的文件,例如:
sudo nano /etc/apt/sources.list.d/cuda.list
注释掉或者删除该行后保存文件。
完成这些步骤后,apt update
应该可以正常运行了。如果问题仍然存在,请告诉我具体的错误信息,我将帮助你进一步排查。
参考资料
https://developer.nvidia.com/zh-cn/blog/updating-the-cuda-linux-gpg-repository-key/
https://wenku.csdn.net/answer/35fbb0cd4f0c4d9fa3fb08df8874690a
https://blog.csdn.net/woshicaiji12138/article/details/130349359
https://cloud.tencent.com/developer/ask/sof/116486343