apt cannot verify the Google Cloud CLI repository signature on Ubuntu
The following signatures could not be verified because the public key is not availableShort 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.
Fix it fast
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.list2Match what you see, then jump to its fix
- 1
The file /usr/share/keyrings/cloud.google.gpg does not existThe key file was never imported, or is missingFix - 2
The 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
The file from the first step lists the cloud-sdk repository more than onceDuplicate cloud-sdk repository entriesFix
- 1
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.gpg2Fix
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.gpg3Verify
Refresh the package index with no signature error.
sudo apt-get updateConfirmed by docs.cloud.google.com
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.list2Fix
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.list3Verify
apt update runs clean.
sudo apt-get updateConfirmed by docs.cloud.google.com
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.list2Fix
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.list3Verify
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 updateConfirmed by docs.cloud.google.com
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix