Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

apt cannot verify the Google Cloud CLI repository signature on Ubuntu

ErrorThe following signatures could not be verified because the public key is not available

Short answer

apt cannot check the signature of the Google Cloud CLI repository because it has no usable public key for it. Re-import the key into /usr/share/keyrings/cloud.google.gpg, make the signed-by path in the repository file match it, and remove duplicate cloud-sdk lines.

  • Applies to Ubuntu 24.04, Google Cloud CLI, apt
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the repository file that apt reads for the Google Cloud CLI. Its signed-by path and its number of lines decide which cause applies.

    cat /etc/apt/sources.list.d/google-cloud-sdk.list
  2. 2Match what you see, then jump to its fix

    1. 1The file /usr/share/keyrings/cloud.google.gpg does not existThe key file was never imported, or is missingFix
    2. 2The repository line has a signed-by value other than /usr/share/keyrings/cloud.google.gpg, or none at allThe signed-by path does not match the keyringFix
    3. 3The file from the first step lists the cloud-sdk repository more than onceDuplicate cloud-sdk repository entriesFix

What does the error look like?

  • The following signatures could not be verified because the public key is not available

Cause 1 of 3

The key file was never imported, or is missing

1Check

Look for the keyring the repository line points to.

ls -l /usr/share/keyrings/cloud.google.gpg

2Fix

Download the signing key again and convert it into the keyring file.

sudo apt-get install ca-certificates gnupg curl
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg

3Verify

Refresh the package index with no signature error.

sudo apt-get update

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 2 of 3

The signed-by path does not match the keyring

1Check

The path in signed-by must be the keyring file you created.

grep signed-by /etc/apt/sources.list.d/google-cloud-sdk.list

2Fix

Replace the line with the documented one. The tee below appends, so remove the old file first.

sudo rm /etc/apt/sources.list.d/google-cloud-sdk.list
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

3Verify

apt update runs clean.

sudo apt-get update

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 3 of 3

Duplicate cloud-sdk repository entries

1Check

Count how many times the repository appears.

grep -c cloud-sdk /etc/apt/sources.list.d/google-cloud-sdk.list

2Fix

Keep one line only. Do the same in other files under sources.list.d if the check finds the repository there.

sudo rm /etc/apt/sources.list.d/google-cloud-sdk.list
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list

3Verify

The count is now 1, and apt update is clean.

grep -c cloud-sdk /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get update

Confirmed by docs.cloud.google.com

Did this fix it?

How do I stop it coming back?

  • Follow the documented install steps in order: key first, repository line second.
  • Use signed-by with a keyring file instead of adding keys to the global apt keyring.
  • Check the file under sources.list.d before you paste the repository line a second time.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.