解决 Debian GPG 错误
2023-09-17 tech linux 6 mins 2104 字
今天对一台新机器更换了源,进行apt-get update
报错:
Err:3 http://mirrors.aliyun.com/debian buster-proposed-updates InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
Err:4 http://mirrors.aliyun.com/debian buster-backports InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
Reading package lists... Done
W: GPG error: http://mirrors.aliyun.com/debian buster-proposed-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
E: The repository 'http://mirrors.aliyun.com/debian buster-proposed-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: http://mirrors.aliyun.com/debian buster-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
E: The repository 'http://mirrors.aliyun.com/debian buster-backports 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.
这是缺少必要的 GPG 公钥导致的。这些公钥用于验证从 http://mirrors.aliyun.com/debian 这个源下载的软件包的完整性。
要解决这个问题,可以按照以下步骤来添加缺少的公钥:
-
先安装
GnuPG
。E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
apt install gnupg
-
找到缺少的公钥的 16 进制指纹,它们在错误消息中可以找到。在这里,这两个指纹分别是
0E98404D386FA1D9
和6ED0E7B82643E131
。 -
使用以下命令将公钥添加到系统中:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 6ED0E7B82643E131
这个命令会从 Ubuntu 的公钥服务器下载并添加这两个公钥到你的系统中。
-
接下来,你需要更新软件包列表,以便使更改生效:
apt update
-
现在,你应该能够正常地更新和安装软件包了。
使用 GPG 密钥来验证软件包的完整性还是有必要的,可以防止恶意软件注入到你的系统中。