Elementary OS 6.1安装gcloud CLI后apt更新GPG密钥错误求解
我在基于Ubuntu 20.04的Elementary OS 6.1系统上安装gcloud CLI,安装过程看似正常,但执行sudo apt update时,仓库出现GPG密钥验证错误:
Err:21 https://packages.cloud.google.com/apt cloud-sdk InRelease
The following signatures could not be verified because their public key is not available: NO_PUBKEY B53DC80D13EDEF05W: GPG error: https://packages.cloud.google.com/apt cloud-sdk InRelease: The following signatures could not be verified because their public key is not available: NO_PUBKEY B53DC80D13EDEF05
E: The repository “https://packages.cloud.google.com/apt cloud-sdk InRelease” is not signed.
尝试执行以下命令修复但无效:
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
手动导入缺失的GPG密钥
直接从Ubuntu密钥服务器获取并导出目标密钥到指定密钥环:gpg --keyserver keyserver.ubuntu.com --recv-keys B53DC80D13EDEF05 gpg --export --armor B53DC80D13EDEF05 | sudo tee /usr/share/keyrings/cloud.google.gpg > /dev/null修正仓库配置文件
确保Google Cloud SDK的仓库配置正确引用密钥环:- 打开配置文件:
sudo nano /etc/apt/sources.list.d/google-cloud-sdk.list - 将内容修改为:
deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main - 保存退出后,更新仓库:
sudo apt update
- 打开配置文件:
一键安装脚本备选方案
如果上述方法仍未解决,使用官方提供的一键安装脚本绕过仓库配置问题:curl https://sdk.cloud.google.com | bash安装完成后,重启终端或执行
source ~/.bashrc(zsh用户执行source ~/.zshrc)加载环境变量。
内容的提问来源于stack exchange,提问作者Pedro Castro

