对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。

验证 Atlas CLI 包的完整性

Atlas CLI发布团队对所有软件包和容器映像进行数字签名,以证明特定包有效且未被更改。在安装适用于Linux、 Windows或Docker的Atlas CLI软件包之前,应使用提供的 PGP 签名、SHA-256校验和或Cosign信息来验证包。

MongoDB 使用不同的 PGP 密钥对每个发布分支进行签名。 最新 Atlas CLI 版本的公钥文件可从密钥服务器下载。

以下过程根据 Atlas CLI 包的 PGP 密钥验证 Atlas CLI 包。

1

根据您的Linux环境,从MongoDB下载中心下载Atlas CLI二进制文件。 单击Copy link并使用以下说明中的URL 。

示例,要通过1.60.1 下载适用于Linux 的shell 发布,请运行以下命令:

curl -LO https://fastdl.mongodb.org/mongocli/mongodb-atlas-cli_1.60.1_linux_x86_64.tar.gz
2

运行以下命令以下载文件:

curl -LO https://fastdl.mongodb.org/mongocli/mongodb-atlas-cli_1.60.1_linux_x86_64.tar.gz.sig
3

执行以下命令以下载并导入密钥文件:

curl -LO https://pgp.mongodb.com/atlas-cli.ascgpg --import atlas-cli.asc
gpg: key <key-value-short>: public key "Atlas CLI Release Signing Key <packaging@mongodb.com>" importedgpg: Total number processed: 1gpg: imported: 1
4

运行以下命令来验证安装文件:

gpg --verify mongodb-atlas-cli_1.60.1_linux_x86_64.tar.gz.sig mongodb-atlas-cli_1.60.1_linux_x86_64.tar.gz
gpg: Signature made Thu Mar 14 08:25:00 2024 EDTgpg: using RSA key <key-value-long>gpg: Good signature from "Atlas CLI Release Signing Key <packaging@mongodb.com>" [unknown]

如果包已正确签名,但目前不信任签名密钥,则 gpg 还将返回以下消息:

gpg: WARNING: This key is not certified with a trusted signature!gpg: There is no indication that the signature belongs to the owner.

以下过程根据 Atlas CLI 包的 SHA-256 密钥验证 Atlas CLI 包。

1

从MongoDB下载中心或Github下载Atlas CLI .msi 或 .zip文件。

2
  1. 从Github下载该发布的 checksums.txt文件,其中包含每个文件的 SHA-256 密钥。示例,对于版本 1.60.1,下载1.60.1 checksums.txt文件。

  2. 打开 checksums.txt 文件并复制下载的包左侧列出的文本。例如,如果您下载了 mongodb-atlas-cli_1.60.1_windows_x86_64.zip,请复制 mongodb-atlas-cli_1.60.1_windows_x86_64.zip 左侧的文本。该值是 SHA-256 密钥值。

  3. 将 SHA-256 密钥值保存在下载文件夹中名为 atlas-cli-key 的 .txt 文件中。

3

运行 Powershell 命令,根据下载的文件验证包。

如果您下载了 mongodb-atlas-cli_1.60.1_windows_x86_64.zip,请运行以下命令:

$sigHash = (Get-Content $Env:HomePath\Downloads\atlas-cli-key.txt | Out-String).SubString(0,64).ToUpper(); `$fileHash = (Get-FileHash $Env:HomePath\Downloads\mongodb-atlas-cli_1.60.1_windows_x86_64.zip).Hash.Trim(); `echo $sigHash; echo $fileHash; `$sigHash -eq $fileHash
<key-value-from-signature-file><key-value-from-downloaded-package>True

如果您下载了 mongodb-atlas-cli_1.60.1_windows_x86_64.msi,请运行以下命令:

$sigHash = (Get-Content $Env:HomePath\Downloads\atlas-cli-key.txt | Out-String).SubString(0,64).ToUpper(); `$fileHash = (Get-FileHash $Env:HomePath\Downloads\mongodb-atlas-cli_1.60.1_windows_x86_64.msi).Hash.Trim(); `echo $sigHash; echo $fileHash; `$sigHash -eq $fileHash
<key-value-from-signature-file><key-value-from-downloaded-package>True

该命令返回签名文件中的键值、下载包中的键值,如果两个值匹配则返回 True 。

如果两个值匹配,则 Atlas CLI 二进制文件通过验证。

您可以使用Cosign 验证 Atlas CLI 和本地 Atlas 部署容器镜像的签名。

要验证容器签名,请执行以下步骤:

1

示例:macOS

brew install cosign

有关完整的安装说明,请参阅 Cosign。

2
curl https://cosign.mongodb.com/atlas-cli.pem > atlas-cli.pem
3

运行以下命令以按标记验证签名:

COSIGN_REPOSITORY=docker.io/mongodb/signatures cosign verify --private-infrastructure --key=./atlas-cli.pem docker.io/mongodb/atlas:latest
Verification for index.docker.io/mongodb/atlas:latest --The following checks were performed on each of these signatures:- The cosign claims were validated- The signatures were verified against the specified public key [{"critical":{"identity":{"docker-reference":"index.docker.io/mongodb/atlas"},"image":{"docker-manifest-digest":"sha256:<key-value>"},"type":"cosign container image signature"},"optional":null}]

您可以验证mongodb/mongodb-atlas-local Docker 映像的签名。

1

示例:

brew install cosign

要学习;了解更多信息,请参阅 cosign 安装。

2

示例:

curl -O https://cosign.mongodb.com/mongodb-atlas-local.pem
COSIGN_REPOSITORY="docker.io/mongodb/signatures" cosign verify --private-infrastructure --key=./mongodb-atlas-local.pem "mongodb/mongodb-atlas-local";