我正在使用安装了 Ubuntu 20.04.3 LTS 的 WSL (windows-for-linux)。运行时sudo apt-get update
出现以下错误:
Err:7 https://apt.kitware.com/ubuntu bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6AF7F09730B3F0A4
Fetched 11.0 kB in 1s (7552 B/s)
我尝试了以下发布的提示: 由于公钥不可用,无法验证以下签名:NO_PUBKEY 但这对我来说不起作用 - gpg 抱怨“没有数据”:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
Executing: /tmp/apt-key-gpghome.Cz3vHTxU7i/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
gpg: keyserver receive failed: No data
我该怎么做才能使 apt-get update 工作?
更新:
根据要求我分享 /etc/apt/source.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
deb https://apt.kitware.com/ubuntu/ bionic main
答案1
我将密钥添加到 Ubuntu 密钥服务器(出于某种原因,他们没有 Kitware apt 存储库的密钥,该存储库于 2022 年更新)
运行这个应该可以解决你的问题:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
答案2
只需按照官方文档:
首先,运行以下命令来安装所有先决条件:
sudo apt-get update sudo apt-get install gpg wget
现在添加 GPG 密钥环:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
更新:
sudo apt-get update
答案3
在你的/etc/apt/sources.list.d/kitware.list
它是:
deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main
因此,该存储库被迫使用/usr/share/keyrings/kitware-archive-keyring.gpg
该公钥进行验证。
apt-key
但是您已经使用全局密钥库(位于/etc/apt/trusted.gpg
和)更新了您的公钥/etc/apt/trusted.gpg.d/
,而不是那个特定的文件。
因此,有两种方法可以使其工作:
- 按照“获取我们的签名密钥的副本”部分的确切说明进行操作https://apt.kitware.com/创建
/usr/share/keyrings/kitware-archive-keyring.gpg
此文件。 - 删除
[signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg]
内部内容/etc/apt/sources.list.d/kitware.list
,以便 apt 可以从全局密钥库中读取相应的公钥。(您仍然需要从某处安装公钥)