概要說明
報告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
更新正常,如絲般順滑。