google-cloud-platformgcloudgcloud-cli

Running `apt update` raises: "GPG error: cloud-sdk is not signed"


While running sudo apt update the following Warning, followed by an Error raises:

W: GPG error: http://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
E: The repository 'http://packages.cloud.google.com/apt cloud-sdk InRelease' is not signed.

Does anybody know how can I solve it?


Solution

  • This is a known issue.

    https://cloud.google.com/compute/docs/troubleshooting/known-issues#keyexpired

    Updated 2024:

    apt-key is deprecated, the new way is to store the keys in separate files.

    Get the latest key with:

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

    and use [signed-by=/usr/share/keyrings/google-keyring.gpg] in package definition file in /etc/apt/sources-list.d/:

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

    Original answer (deprecated)

    Run the following command to obtain the latest key:

    wget https://packages.cloud.google.com/apt/doc/apt-key.gpg \
        && apt-key add apt-key.gpg
    

    or

    curl -O https://packages.cloud.google.com/apt/doc/apt-key.gpg \
        && apt-key add apt-key.gpg
    

    or.. if you like it simple without extraneous files and are feeling adventurous:

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