23

The old QGIS key ring qgis-2017.gpg.key is expired and generates a warning during apt update today.

Following the QGIS instructions, I tried to update the key as follows:

wget -O - https://qgis.org/downloads/qgis-2019.gpg.key | gpg --import
gpg --fingerprint 51F523511C7028C3

But instead of the normal output, I get an error:

$ wget -O - https://qgis.org/downloads/qgis-2019.gpg.key | gpg --import
--2019-08-16 18:36:35--  https://qgis.org/downloads/qgis-2019.gpg.key
Resolving qgis.org (qgis.org)... 104.27.138.220, 104.27.139.220, 2606:4700:30::681b:8bdc, ...
Connecting to qgis.org (qgis.org)|104.27.138.220|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1839 (1.8K) [application/pgp-keys]
Saving to: ‘STDOUT’

-                   100%[===================>]   1.80K  --.-KB/s    in 0s      

2019-08-16 18:36:35 (33.3 MB/s) - written to stdout [1839/1839]

gpg: key 51F523511C7028C3: 1 signature not checked due to a missing key
gpg: no writable keyring found: Not found
gpg: error reading '[stdin]': General error
gpg: import from '[stdin]' failed: General error
gpg: Total number processed: 0

How can I fix the error please?

3
  • what apt repository are you using? The one for "cosmic" still uses the expired 2017 key :-(
    – Dakatine
    Aug 19, 2019 at 12:25
  • 2
    @Dakatine I am using deb https://qgis.org/debian bionic main in /etc/apt/sources.list.
    – tinlyx
    Aug 19, 2019 at 23:28
  • thank you. Unfortunately it is not working here on Ubuntu 10.10.
    – Dakatine
    Aug 20, 2019 at 14:36

3 Answers 3

54

Based on old notes, the following seems to work:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 51F523511C7028C3

-- Update --

As of August 2020:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F7E06F06199EF2F2

As of August 2021:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 46B5721DBBD2996A

Or alternatively, as pointed out by 4ndts's answer (and in the updated documentation):

wget -qO - https://qgis.org/downloads/qgis-$(date +%Y).gpg.key | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import
2
  • 2
    On Ubuntu 19.04 this also solved the following problem 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: qgis.org/debian disco InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51F523511C7028C3
    – Dennis
    Aug 18, 2019 at 20:04
  • On Ubuntu 16.04 (Xenial) this is not working. When I try to update I get "W: Failed to fetch qgis.org/ubuntugis/dists/xenial/InRelease The following signatures were invalid: KEYEXPIRED 1565999960"
    – Daniel
    Aug 22, 2019 at 14:40
9

After you have verified the fingerprint you forgot to add the key to apt with:

gpg --export --armor 51F523511C7028C3 | sudo apt-key add -  

Read the QGIS documentation. All the instructions are:

wget -O - https://qgis.org/downloads/qgis-2019.gpg.key | gpg --import
gpg --fingerprint 51F523511C7028C3
gpg --export --armor 51F523511C7028C3 | sudo apt-key add -
1

gpg --fingerprint 51F523511C7028C3 returns uid [ expired].

There's a 2021 key:

wget -qO - https://qgis.org/downloads/qgis-2021.gpg.key | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/qgis-archive.gpg --import

sudo chmod a+r /etc/apt/trusted.gpg.d/qgis-archive.gpg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.