ubuntu添加软件源后报错NO_PUBKEY

问题描述

当我们需要在Ubuntu中安装一些程序时,需要在software&updates-other software中添加第三方源。

ubuntu添加软件源后报错NO_PUBKEY

而添加后在终端中运行

sudo apt-get update 

更新软件列表时候,会因为无法匹配公匙报错:

“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 XXXXX”

具体例子:

 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

解决方法

添加公匙一解决这一问题 :

下面这行命令中的XXXXX和报错中提示的XXXXX应该保持一致,并讲报错中提示的所有公匙都安装(好像不全安装也没有问题,安装1个就可以,但没试过)

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com XXXXX

具体例子:

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

如果公匙安装成功会出现类似以下提示:

 Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.w8njroYZkC --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: key 437D05B5: public key "Ubuntu Archive Automatic Signing Key <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1

之后在运行以下命令就应该不会有公匙问题了。 

sudo apt-get update