您的浏览器过于古老 & 陈旧。为了更好的访问体验, 请 升级你的浏览器
代码玩家 发布于2024年02月18日 15:21 最近更新于 2024年02月18日 15:55

执行 sudo apt update 时报 GPG error 错误

1145 次浏览 读完需要≈ 3 分钟 Linux

在 Ubuntu 系统上执行 sudo apt-get update; sudo apt-get upgrade 命令更新软件列表时出错,报错信息如下:

Reading package lists... Done                                
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/ubuntu trusty-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu trusty-updates 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.
W: GPG error: https://mirrors.tuna.tsinghua.edu.cn/ubuntu trusty-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32

请问,该怎么做才能正确地完成软件更新呢 ?

1 个回答

Ready · 8个月前

出现该问题,主要是因为你更换了Ubuntu的系统软件镜像源之后,由于缺少对应的公钥证书,导致验签失败。

你可以执行如下命令从密钥服务器中下载对应的公钥证书,并添加到受信任的证书集中。

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32

【注意】将上述命令中最后的参数替换为报错信息中实际的公钥指纹ID,如果有多个,可以用空格隔开。

可以参考:https://manpages.ubuntu.com/manpages/xenial/man8/apt-key.8.html

常见的密钥服务器有如下几个:

不过,也要注意,这个命令已经被标记为过时(deprecated) 了,因为直接向 /etc/apt/trusted.gpg.d 添加密钥是不安全的,添加的该密钥将被系统上的所有存储库(repository)信任。

到此就先告一段落吧~

撰写答案