apt-get update报告GPG error的解法

概要说明

报告GPG error的原因,大部分是因为本地缺少相应的Public key,只需按照错误提示,把public key添加到本地信任列表即可。
下面以访问nvidia repo的异常举例说明。

apt-get update报错信息

root@~:/etc/apt/sources.list.d# apt-get update
......
Hit:5 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Ign:6 http://download.bareos.org/bareos/release/17.2/xUbuntu_16.04 InRelease
Hit:7 http://download.bareos.org/bareos/release/17.2/xUbuntu_16.04 Release
Hit:9 https://download.docker.com/linux/ubuntu xenial InRelease
Ign:10 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 InRelease
Get:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release [169 B]
Get:12 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release.gpg [169 B]
Ign:12 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release.gpg
Hit:13 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Packages
Fetched 1,397 B in 16s (86 B/s)
Reading package lists... Done
W: GPG error: https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F60F4B3D7FA2AF80
W: The repository 'https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解决方法

安装apt-transport-https

apt-get install -y apt-transport-https

将相应apt source配置文件中的http更换为https

例如将/etc/apt/sources.list.d/nvidia-ml.list中的
deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /
更换为:deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /

更新apt-key

查看 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 页面并找到 .pub 文件,然后用.pub更新apt-key,
例如下面的命令:
wget -qO - https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/7fa2af80.pub | sudo apt-key add -

验证apt-get update

root@~:/etc/apt/sources.list.d# apt-get update
......
Hit:6 https://download.docker.com/linux/ubuntu xenial InRelease
Hit:5 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Ign:7 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 InRelease
Ign:8 http://download.bareos.org/bareos/release/17.2/xUbuntu_16.04 InRelease
Hit:9 http://download.bareos.org/bareos/release/17.2/xUbuntu_16.04 Release
Hit:11 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 Release
Reading package lists... Done
更新正常,如丝般顺滑。

posted @ 2020-08-21 18:32  shliph  阅读(4435)  评论(1编辑  收藏  举报