You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04 LTS执行sudo apt update失败,提示缺失公钥及仓库未签名

Ubuntu 22.04 LTS执行sudo apt update失败,提示缺失公钥及仓库未签名

先把你遇到的错误信息整理出来,方便定位问题:

It is giving the following error

The following signatures couldn't be verified because the public key is not available: NO_PUBKEY xxxxxxxxxxxxxx

Get:4 https://packages.microsoft.com/repos/ms-teams stable InRelease [5,931 B]

Hit:12 https://ppa.launchpadcontent.net/tomtomtom/woeusb/ubuntu jammy InRelease

Hit:13 https://ppa.launchpadcontent.net/ubuntuhandbook1/gimp/ubuntu jammy InRelease

Reading package lists... Done

W: GPG error: https://dl.winehq.org/wine-builds/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY xxxxxxxx

E: The repository 'https://dl.winehq.org/wine-builds/ubuntu jammy 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.

这个问题我之前也碰到过,核心原因就是你的系统缺少了WineHQ仓库对应的GPG签名公钥,apt没法验证这个第三方仓库的安全性,所以才会抛出这些错误阻止更新。下面是具体的解决步骤:

  • 第一步:先把错误信息里NO_PUBKEY后面的一串字符(也就是公钥ID,比如你这里的xxxxxxxx和xxxxxxxxxxxxxx)记下来
  • 第二步:导入对应的公钥,推荐用官方现在更推荐的安全方法(因为旧的apt-key已经被弃用了):
    针对每个缺失的公钥ID,执行以下两条命令(把命令里的xxxxxxxxx替换成你实际的公钥ID):
    gpg --keyserver keyserver.ubuntu.com --recv-keys xxxxxxxxx
    gpg --export xxxxxxxxx | sudo tee /usr/share/keyrings/winehq-archive-keyring.gpg > /dev/null
    
    要是你习惯用旧方法,也可以执行这条(不推荐长期使用):
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys xxxxxxxxx
    
  • 第三步:重新执行更新命令,看看问题是否解决:
    sudo apt update
    

简单解释下:导入公钥后,系统就能识别并信任WineHQ仓库的签名,自然就能正常拉取更新了。如果之后还有其他仓库报类似的公钥缺失错误,重复上面的步骤导入对应公钥就行。

备注:内容来源于stack exchange,提问作者Anupam Bhattacharyya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 11:12:59