无法完成 MongoDB 安装 Ubuntu 22.04

无法完成 MongoDB 安装 Ubuntu 22.04

我正在跟进MongoDB 官方指南在 Ubuntu 22.04 上安装,但我无法完成第三步。我尝试导入公钥并创建列表文件。当我尝试执行时,sudo apt update我收到以下输出:

Hit:1 http://packages.microsoft.com/repos/code stable InRelease
Hit:2 http://apt.pop-os.org/proprietary jammy InRelease                                   
Ign:3 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 InRelease                 
Hit:4 https://download.docker.com/linux/ubuntu jammy InRelease                            
Hit:5 https://download.ni.com/ni-linux-desktop/LabVIEW/2023/Q1/f0/community/deb/ni-labview-2023/jammy jammy InRelease
Hit:6 http://apt.pop-os.org/release jammy InRelease                 
Hit:7 https://download.ni.com/ni-linux-desktop/2023/Q1/deb/ni/jammy jammy InRelease
Hit:8 http://apt.pop-os.org/ubuntu jammy InRelease                  
Hit:9 http://apt.pop-os.org/ubuntu jammy-security InRelease
Get:10 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 Release [3,094 B]
Hit:11 http://apt.pop-os.org/ubuntu jammy-updates InRelease
Hit:12 http://apt.pop-os.org/ubuntu jammy-backports InRelease
Get:13 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 Release.gpg [801 B]
Ign:13 https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 Release.gpg
Reading package lists... Done
W: GPG error: https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A26B1AE64C3C388
E: The repository 'https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 Release' 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.

在执行指南提供的以下命令导入公钥后,我注意到该文件/usr/share/keyrings/mongodb-server-6.0.gpg尚未被创建。

curl -fsSL https://pgp.mongodb.com/server-6.0.pub | sudo gpg -vv -o /usr/share/keyrings/mongodb-server-6.0.gpg

输出:

gpg: WARNING: no command supplied.  Trying to guess what you mean ...
# off=0 ctb=99 tag=6 hlen=3 plen=525
:public key packet:
    version 4, algo 1, created 1645629114, expires 0
    pkey[0]: [4096 bits]
    pkey[1]: [17 bits]
    keyid: 6A26B1AE64C3C388
# off=528 ctb=b4 tag=13 hlen=2 plen=55
:user ID packet: "MongoDB 6.0 Release Signing Key <[email protected]>"
# off=585 ctb=89 tag=2 hlen=3 plen=574
:signature packet: algo 1, keyid 6A26B1AE64C3C388
    version 4, created 1645629114, md5len 0, sigclass 0x13
    digest algo 2, begin of digest 00 e1
    hashed subpkt 2 len 4 (sig created 2022-02-23)
    hashed subpkt 27 len 1 (key flags: 03)
    hashed subpkt 9 len 4 (key expires after 5y0d0h0m)
    hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2)
    hashed subpkt 21 len 5 (pref-hash-algos: 8 2 9 10 11)
    hashed subpkt 22 len 3 (pref-zip-algos: 2 3 1)
    hashed subpkt 30 len 1 (features: 01)
    hashed subpkt 23 len 1 (keyserver preferences: 80)
    subpkt 16 len 8 (issuer key ID 6A26B1AE64C3C388)
    data: [4096 bits]
pub   rsa4096 2022-02-23 [SC] [expires: 2027-02-22]
      39BD841E4BE5FB195A65400E6A26B1AE64C3C388
uid           MongoDB 6.0 Release Signing Key <[email protected]>
sig        6A26B1AE64C3C388 2022-02-23   [selfsig]

我该如何解决此错误?我是否未正确导入公钥?

答案1

我可以通过执行以下操作来导入密钥:

curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-server-6.0.gpg

然后我适当地更新了列表文件:

echo "deb [ arch=amd64,arm64 signed=/etc/apt/trusted.gpg.d/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

相关内容