17

I am using WSL (windows-for-linux) with installed Ubuntu 20.04.3 LTS. When I run sudo apt-get update I get following error:

Err:7 https://apt.kitware.com/ubuntu bionic InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6AF7F09730B3F0A4
Fetched 11.0 kB in 1s (7552 B/s)

I tried the tips posted in: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY but that does not work for me - gpg complains about "no data":

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
Executing: /tmp/apt-key-gpghome.Cz3vHTxU7i/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
gpg: keyserver receive failed: No data

What shall I do to make apt-get update work?

UPDATE:

As requested I share /etc/apt/source.list

deb http://archive.ubuntu.com/ubuntu/ focal main restricted
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted deb http://security.ubuntu.com/ubuntu/ focal-security universe deb http://security.ubuntu.com/ubuntu/ focal-security multiverse deb https://apt.kitware.com/ubuntu/ bionic main

Error404
  • 7,440
Ivan Angelov
  • 171
  • 1
  • 1
  • 6
  • If you're on 20.04 or focal, why does your paste show bionic or 18.04 ? – guiverc Jan 28 '22 at 11:49
  • 1
    Just follow the instructions: https://apt.kitware.com/ – Johan Palych Jan 28 '22 at 12:59
  • "If you're on 20.04 or focal, why does your paste show bionic or 18.04" I am suspecting big part of my problem is related to WSL (windows for linux) but I have no idea what to do to fix my issues. – Ivan Angelov Jan 31 '22 at 08:57
  • I tried to fix your question by correcting the typo you made ("source.list" should be "sources.list") but I received an error from Stack Overflow: "Edits must be at least 6 characters; is there something else to improve in this post?". So I'm leaving this comment here in case someone runs into this issue. – Matt Welke Mar 25 '23 at 21:04

3 Answers3

17

I added the key to the Ubuntu keyserver (for some reason, they didn't have the key for the Kitware apt repository, which was updated in 2022)

Running this should solve your problem now:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4
d4rk_kn1gh7
  • 171
  • 2
6

Just follow the official documentation:

  1. Initially, run the following command to install all the prerequisites:

    sudo apt-get update
    sudo apt-get install gpg wget
    
  2. Now add the GPG keyring:

    wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
    
  3. Update:

    sudo apt-get update
    
Error404
  • 7,440
  • that sequence did not work for me.

    W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://apt.kitware.com/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6AF7F09730B3F0A4

    W: Failed to fetch https://apt.kitware.com/ubuntu/dists/bionic/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6AF7F09730B3F0A4

    – Ivan Angelov Jan 31 '22 at 08:54
  • Run apt update and try again! – Error404 Jan 31 '22 at 08:55
  • it still does not work. – Ivan Angelov Jan 31 '22 at 08:56
  • Remove the repository and try again. – Error404 Jan 31 '22 at 08:56
  • Edit your question to add the output of cat /etc/apt/sources.list – Error404 Jan 31 '22 at 08:57
  • 1
    The error is because you are using the Bionic repository in focal. @IvanAngelov Also, you should avoid using apt key as it's deprecated. – Error404 Feb 16 '22 at 13:27
6

In your /etc/apt/sources.list.d/kitware.list it's:

deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main

So this repository is forced to validate with /usr/share/keyrings/kitware-archive-keyring.gpg this public key.

But you have updated your public key with apt-key global keystore (which is in /etc/apt/trusted.gpg and /etc/apt/trusted.gpg.d/), not that specific file.

So there are two ways to make it work:

  • Follow the exact instructions of "Obtain a copy of our signing key" section in https://apt.kitware.com/ to create /usr/share/keyrings/kitware-archive-keyring.gpg this file.
  • Remove [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] inside /etc/apt/sources.list.d/kitware.list so that apt can read the corresponding public key from global keystore. (You still need to install the public key from somewhere)
Gea-Suan Lin
  • 406
  • 4
  • 7