65

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.

13 Answers 13

124

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
4
  • mark for right answer man!
    – MagicHat
    Apr 13, 2018 at 9: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 3, 2019 at 23:00
  • 5
    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, 2021 at 9:10
  • The 2nd one wasn't working for me, but the 1st one did. Thanks.
    – tzp
    Mar 6, 2023 at 9:27
25
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
3
  • it's same as my answer...
    – alexus
    Apr 6, 2021 at 19:56
  • 1
    When using @alexus method, I get (23) Failed writing body, however this worked for me.
    – tom
    Apr 10, 2021 at 5:07
  • 6
    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, 2021 at 6:50
11

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
1
  • 3
    Thank you, editing /etc/apt/sources.list.d/google-cloud-sdk.list worked for me.
    – Julien__
    Jul 29, 2020 at 10:27
3

In ubuntu 22+

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
1
  • This was the only solution that worked with Debain Bookworm
    – PassKit
    Aug 23, 2023 at 9:04
2

I was getting a similar error:

Err:4 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 B53DC80D13EDEF05

None of these answers worked for me.

I ended up having to delete the google cloud entry from my /etc/apt/sources.list.d/:

sudo rm /etc/apt/sources.list.d/google-cloud-sdk.list*

And this deleted the following entries for me:

google-cloud-sdk.list
google-cloud-sdk.list.distUpgrade
google-cloud-sdk.list.save

For your situation, you may need to find and delete the /etc/apt/sources.list.d/ entries that correspond to cloud-sdk-stretch.

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
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
-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

-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

-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

2
  • Welcome to Server Fault! How is your answer different from the accepted answer?
    – Paul
    Dec 5, 2021 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 Dec 5, 2021 at 20:01
-1

Solution:

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
apt-get clean
apt update --fix-missing
3
  • it works for me, why negative note !
    – S.Bao
    Jun 21, 2023 at 9:20
  • What's with the missing command: sudo apt-key add -... There's something missing there, I think. Dec 27, 2023 at 1:19
  • it was already answered, in the same way.
    – djdomi
    Mar 29 at 13:13
-3

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

sudo launchpad-getkeys

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .