41

My environment:

# uname -a
Linux app11 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux
# 
# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# 

while trying to run apt-get update, I get bunch of errors:

# apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Hit:2 http://security.debian.org stretch/updates InRelease
Hit:3 http://deb.debian.org/debian stretch-updates InRelease             
Hit:4 http://deb.debian.org/debian stretch-backports InRelease           
Hit:5 http://deb.debian.org/debian stretch Release 
Get:6 http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease [6,377 B]
Ign:7 https://artifacts.elastic.co/packages/6.x/apt stable InRelease
Hit:8 https://artifacts.elastic.co/packages/6.x/apt stable Release
Get:9 http://packages.cloud.google.com/apt google-compute-engine-stretch-stable InRelease [3,843 B]
Get:10 http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-stretch InRelease [3,876 B]
Hit:11 https://download.docker.com/linux/debian stretch InRelease
Err:6 http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
Err:9 http://packages.cloud.google.com/apt google-compute-engine-stretch-stable InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
Err:10 http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-stretch InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
Fetched 6,377 B in 0s (7,132 B/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com/apt google-compute-engine-stretch-stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
W: Failed to fetch http://packages.cloud.google.com/apt/dists/cloud-sdk-stretch/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
W: Failed to fetch http://packages.cloud.google.com/apt/dists/google-compute-engine-stretch-stable/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
W: Failed to fetch http://packages.cloud.google.com/apt/dists/google-cloud-packages-archive-keyring-stretch/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A030B21BA07F4FB
W: Some index files failed to download. They have been ignored, or old ones used instead.
# 

Please advise.

alexus
  • 12,342
  • 27
  • 115
  • 173

10 Answers10

84

Per Installing Google Cloud SDK  |  Cloud SDK Documentation - Debian/Ubuntu:

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

OR

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

follow by:

sudo apt-get update
alexus
  • 12,342
  • 27
  • 115
  • 173
  • mark for right answer man! – MagicHat Apr 13 '18 at 09:17
  • 3
    On my system I get this output: `gpg: WARNING: nothing exported gpg: no valid OpenPGP data found. gpg: Total number processed: 0` – Pietro Feb 03 '19 at 23:00
  • 2
    Same error, `NO_PUBKEY FEEA9169307EA071 NO_PUBKEY 8B57C5C2836F4BEB`. That's because `google-cloud-sdk.list` has `[signed-by=/usr/share/keyrings/cloud.google.gpg]`. So you should update that keyring instead of the default one. – rustyx May 20 '21 at 09:10
20
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
alexus
  • 12,342
  • 27
  • 115
  • 173
Ferretti
  • 309
  • 2
  • 2
  • it's same as my answer... – alexus Apr 06 '21 at 19:56
  • 1
    When using @alexus method, I get `(23) Failed writing body`, however this worked for me. – tom Apr 10 '21 at 05:07
  • 5
    Using @alexus method fail but this one work on Ubuntu Focal. It's look like `--keyring /usr/share/keyrings/cloud.google.gpg` make the difference. – ucsky Apr 19 '21 at 06:50
10

The accepted answer didn't work for me.

Eventually I noticed that to install the google sdk I used the following, copied directly from the google documentation:

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
sudo apt-get update && sudo apt-get install google-cloud-sdk

Eventually I noticed that /etc/apt/sources.list.d/google-cloud-sdk.list had a reference to a gpg file, which I thought might be the offending "NO_PUBKEY 6A030B21BA07F4FB" mismatch:

deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main

When I went to open the gpg file (/usr/share/keyrings/cloud.google.gpg) it didn't exist. So I edited google-cloud-sdk.list to remove the reference:

deb https://packages.cloud.google.com/apt cloud-sdk main

And after that, I was able to update with apt-get update without issue.

Slightly off topic - fixing previous google sdk install

Then I remembered that installed the google sdk and kubectl using snap, because I got an error, and I hoped this might fix it. The installer suggested snap when it couldn't find the proper repositories.

My original install commands:

snap install google-cloud-sdk --classic
snap install google-cloud-sdk --classic

So, I removed the snap versions and installed the regular versions.

snap remove google-cloud-sdk
snap remove kubectl
sudo apt-get install kubectl
sudo apt-get install google-cloud-sdk
geneorama
  • 209
  • 2
  • 3
0

The official google documentation has the answer to this:

Troubleshooting Tip: If your distribution does not support the signed-by option run this command instead:

echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

See Debian/Ubuntu > Installation (last paragraph): https://cloud.google.com/sdk/docs/install#installation_instructions

0

Not sure why, but on ubuntu 20.04 that I stood up in Azure I had to switch using curl to wget:

wget https://packages.cloud.google.com/apt/doc/apt-key.gpg 
cat apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update -y
TristanK
  • 8,953
  • 2
  • 27
  • 39
user372429
  • 111
  • 2
0

As the accepted answer doesn't work in my case (debian container), This is the command I had to run for it to work (found here):

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B57C5C2836F4BEB  FEEA9169307EA071
BiAiB
  • 101
  • 1
-1

On your terminal:

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

Sources

mrroot5
  • 99
  • 1
-1

The following command works for me as of May 2021:

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

Source: this thread the gce-discussion Google Groups board

Andrei
  • 99
-1

Problem was all about updating Key with GCP (this problem come for Ubuntu running on Google Cloud Platform). so to updating Public key is required :

Following Cmd update the Key (i.e register Ubuntu with GCP server) :

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

Update Key in machine (Refresh)

sudo apt get update

  • Welcome to Server Fault! How is your answer different from the accepted answer? – Paul Dec 05 '21 at 19:40
  • hey @Paul I wanted to upvote the accepted answer, but since I don't have that reputation (for now), so added as answer. Thank You for noticing – Harbhajan Rai Dec 05 '21 at 20:01
-3

I had similar problem, but nothing worked for me except of this

sudo launchpad-getkeys