在 Pop!_OS 22.04 中使用 sudo apt update 时收到 GPG 错误

在 Pop!_OS 22.04 中使用 sudo apt update 时收到 GPG 错误

我在终端中运行了这个命令:

sudo apt update

最后我收到了这样一条消息:

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.microsoft.com/repos/edge stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
W: Failed to fetch https://packages.microsoft.com/repos/edge/dists/stable/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
W: Some index files failed to download. They have been ignored, or old ones used instead.``` 

Currently running Pop!_OS 22.04 which is based on Ubuntu 22.04

答案1

您应该从这里安装公钥:
https://packages.microsoft.com/keys/microsoft.asc

然后尝试安装/更新 Microsoft 的软件包。
你可以检查这里如何将此密钥添加到您的发行版中。

答案2

apt-key 现在似乎已被弃用,我创建了一个脚本来检测并获取丢失的密钥,你可以获取它这里

#!/bin/sh -e
tmp="$(mktemp)"
sudo apt-get update 2>&1 | sed -En 's/.*NO_PUBKEY ([[:xdigit:]]+).*/\1/p' | sort -u > "${tmp}"
cat "${tmp}" | xargs sudo gpg --keyserver "hkps://keyserver.ubuntu.com:443" --recv-keys  # to /usr/share/keyrings/*
cat "${tmp}" | xargs -L 1 sh -c 'sudo gpg --yes --output "/etc/apt/trusted.gpg.d/$1.gpg" --export "$1"' sh  # to /etc/apt/trusted.gpg.d/*
rm "${tmp}"

相关内容