以下签名无法验证,因为公钥不可用:NO_PUBKEY 2F59B5F99B1BE0B4 in linux

问题描述 投票:0回答:1

我使用的是 Ubuntu 22.04 系统,当我尝试运行时

sudo apt update

出现以下错误:

vijay@vijay-ThinkPad-E15-Gen-2:~$ sudo apt-get update
Get:1 file:/var/cuda-repo-ubuntu2004-11-2-local  InRelease
Ign:1 file:/var/cuda-repo-ubuntu2004-11-2-local  InRelease
Get:2 file:/var/cuda-repo-ubuntu2204-12-4-local  InRelease [1,572 B]
Get:3 file:/var/cudnn-local-repo-ubuntu2204-9.0.0  InRelease [1,572 B]
Get:2 file:/var/cuda-repo-ubuntu2204-12-4-local  InRelease [1,572 B]
Get:4 file:/var/cuda-repo-ubuntu2004-11-2-local  Release [564 B]
Get:3 file:/var/cudnn-local-repo-ubuntu2204-9.0.0  InRelease [1,572 B]
Get:4 file:/var/cuda-repo-ubuntu2004-11-2-local  Release [564 B]
Hit:6 https://deb.nodesource.com/node_18.x nodistro InRelease                                                                                                                                              
Hit:7 https://packages.microsoft.com/repos/code stable InRelease                                                                                                                                           
Err:6 https://deb.nodesource.com/node_18.x nodistro InRelease                                                                                                                   
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2F59B5F99B1BE0B4
Hit:8 https://dl.google.com/linux/chrome/deb stable InRelease                                                                                                  
Hit:9 http://security.ubuntu.com/ubuntu jammy-security InRelease                                                                                               
Hit:10 http://in.archive.ubuntu.com/ubuntu jammy InRelease                                                                               
Hit:11 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease               
Hit:12 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:13 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease
Reading package lists... Done
W: file:/var/cuda-repo-ubuntu2004-11-2-local/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://deb.nodesource.com/node_18.x nodistro InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2F59B5F99B1BE0B4
W: Failed to fetch https://deb.nodesource.com/node_18.x/dists/nodistro/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2F59B5F99B1BE0B4
W: Some index files failed to download. They have been ignored, or old ones used instead.

我已检查以解决此问题,我得到了类似以下命令的解决方案:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 2F59B5F99B1BE0B4

执行结果如下:

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.5riFaj3RU8/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 2F59B5F99B1BE0B4
gpg: key 2F59B5F99B1BE0B4: "NSolid <[email protected]>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

但这并没有解决问题。当我再次跑步时

 sudo apt update 

它抛出同样的错误。

我不知道如何解决这个问题。如何调试确切的问题。

linux ubuntu apt ubuntu-22.04
1个回答
0
投票

我查找了有关此问题的更多信息,发现这篇文章我认为可能会解决您的第二个问题(apt-key)以最终解决您的第一个问题(签名验证问题)

我将在下面恢复该帖子的内容,尽管我鼓励您阅读该帖子,因为它解释了为什么

apt-key
被弃用以及它带来的巨大安全风险。

步骤如下:

  • 下载密钥:
  • wget https://host.domain.tld/path/to/<keyfile>.<ext>

(不需要

-O
>
wget
默认将文件保存在当前目录中,文件名与服务器上的文件名相同。)

  • 验证文件类型是否为“PGP 公钥块 Public-Key(旧)”: -

    file <keyfile>.<ext>

  • gpg
    支持多种密钥格式,因此如果您的密钥采用不同的格式,请通过将其导入临时密钥环进行转换,然后再次导出:

    • gpg --no-default-keyring --keyring ./temp-keyring.gpg --import <keyfile>.<ext>

    • gpg --no-default-keyring --keyring ./temp-keyring.gpg --export --output <your-keyfile-name>.gpg

    • rm temp-keyring.gpg

现在您已经有了转换后的密钥,不要通过将其复制到

apt
来将其添加到
/etc/apt/trusted.gpg.d/
的可信密钥库中。相反,请将其放在类似
/etc/apt/keyrings/
的位置。 (您可能需要先创建该
keyrings
目录。)该位置没有什么特别的,它只是 Ubuntu 22.04 中
man 5 sources.list
和相关 Debian Wiki 条目推荐的约定。

此时,什么都没有改变,并且

apt
不知道密钥存在。最后一步是修改存储库的特定
.list
文件,以告诉 apt 在哪里可以找到 该特定 存储库的密钥。

编辑文件

/etc/apt/sources.list.d/<example>.list
,然后在
deb
和 url 之间添加
[signed-by=/etc/apt/keyrings/<your-keyfile-name>.gpg]

现在 apt 将接受该存储库中所有软件包的密钥签名,并且该存储库。

备注:

  • 如果您在

    /etc/apt/trusted.gpg.d/
    中已有密钥环文件,您可以按原样 move 将它们移动到
    /etc/apt/keyrings/
    ,然后更新所有相应的
    .list
    文件,以便每个文件都有一个指向其自己的
    signed-by
    字段关键。

  • 如果您在

    /etc/apt/trusted.gpg
    密钥环文件中已经拥有官方存储库密钥之外的密钥,此答案详细介绍了查找和删除它们的步骤。然后,您可以按照上述所有相同步骤以更安全的方式进行设置。 (也可以从该密钥环导出它们,但确切的步骤留给读者作为练习。)

  • 要将存储库的密钥从密钥服务器导入到独立文件:

    • gpg --no-default-keyring --keyring <output-file-name>.gpg --keyserver <some.keyserver.uri> --recv-keys <fingerprint>

    • 这应该给你一个 apt 无需转换即可接受的密钥。

  • Apt 仍然非常值得信任,恶意或受损的存储库可以轻松绕过此措施,因为软件包当前可以在其安装脚本中以 root 身份运行任意 shell 代码。不过,关闭一个攻击向量并没有什么坏处,而且其他方面正在(缓慢地)取得进展。

  • 您可以选择使用单独的

    Deb822
    文件而不是
    .sources
    文件切换到更新、更详细的
    .list
    格式。这需要更多工作,但我个人发现结果更具可读性。

来源:

再次强调,这个答案来自

这篇文章,希望它能解决您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.