Ubuntu apt-get public key报错

原文地址:

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

在Ubuntu中执行

apt-get update

命令时,有时候会显示如下错误信息:

[chris@server ~]$ sudo apt-get update
Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
...
Fetched 21.9 MB in 14s (1,537 kB/s)
Reading package lists... Done
W: GPG error: http://security.ubuntu.com trusty-security Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.canonical.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com trusty-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
[chris@server ~]$ 

如果不修复这个报错,apt在后续将不能正常执行软件包的安装和升级等操作,例如:

[chris@server ~]$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
...
E: Some packages could not be authenticated
[chris@server ~]$ 

仔细查看报错,其提示系统缺失了一些PUBKEY

Apt软件包管理系统内置了一个密钥集合,只有通过密钥认证的软件包才能够安装到系统中,正如本次报错所示。

针对这一错误,可以通过apt-key命令来将缺失的PUBKEY添加到系统的密钥库中。

接下来,把错误提示中的两个PUBKEY: 40976EAF437D05B5  3B4FE6ACC0B21F32

通过ape-key命令添加至密钥库,然后重新执行软件包的安装即可。

[chris@server ~]$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.QTeppiINUh --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: key 437D05B5: public key "Ubuntu Archive Automatic Signing Key " imported
gpg: Total number processed: 1
gpg:               imported: 1
[chris@server ~]$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.77TqYGKU7b --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
gpg: requesting key C0B21F32 from hkp server keyserver.ubuntu.com
gpg: key C0B21F32: public key "Ubuntu Archive Automatic Signing Key (2012) " imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
[chris@server ~]$ 

猜你喜欢

转载自blog.csdn.net/Dancen/article/details/125646845