在 Debian 10 中安装 Google SDK?

Installing Google SDK in Debian 10?

我正在按照说明 here 安装 Google Cloud SDK:

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk

但在更新 APT 时

$ sudo apt update
Hit:1 http://ftp.debian.org/debian unstable InRelease
Hit:2 http://deb.debian.org/debian experimental InRelease                                                         
Hit:3 https://updates.signal.org/desktop/apt xenial InRelease                                                     
Get:5 https://packages.cloud.google.com/apt cloud-sdk InRelease [6,337 B]                      
Err:5 https://packages.cloud.google.com/apt cloud-sdk InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
Hit:4 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
Reading package lists... Done
W: GPG error: https://packages.cloud.google.com/apt cloud-sdk InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
E: The repository 'https://packages.cloud.google.com/apt cloud-sdk 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.

并添加密钥

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

使用 Debian 版本

$ cat /etc/issue
Debian GNU/Linux 10 \n \l

如何在 Debian 10 中正确安装 Google Cloud SDK?

PO 的 Google 支持手册 here is outdated. The new thread here 修复了问题:

# Add the Cloud SDK distribution URI as a package source
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

# Import the Google Cloud Platform public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -

# Update the package list and install the Cloud SDK
sudo apt-get update && sudo apt-get install google-cloud-sdk

最简单的方法(在 debian VM 或容器中):

  1. apt-get update && apt-get install -y curl python
  2. curl sdk.cloud.google.com -L | bash

退出 VM(或容器)并再次访问它。

  1. gcloud init

大功告成。