The following signatures couldn’t be verified because the public key is not available

When running a ubuntu or debian based distro, it is sometimes required to do same manual updating with the apt-get tool . I run the following command almost on a daily basis on my desktops and servers.

sudo apt-get update && sudo apt-get dist-upgrade

Of course I could also use the auto-update feature but I like to have more control over what and when I update.

A couple of days ago I ran into a situation where a public key of a repository had expired. The console gave me the following results

Reading package lists... Done
W: GPG error: http://repository.spotify.com stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 082CCEDF94558F59

First I thought there was a problem at te servers of spotify, but doing the following command gave me the answer I was looking for.

daniel@workstation3:~$ sudo apt-key list | grep -B 1 "spotify"
pub   1024D/4E9CFF4E 2010-06-23 [expired: 2012-06-22]
uid                  Spotify Public Repository Signing Key <operations@spotify.com>

The solution in this case was very simple. I removed the expired public key and added the new public key from spotify.

daniel@workstation3:~$ sudo apt-key del 4E9CFF4E
OK
daniel@workstation3:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.iqNIZAJxKg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 94558F59
gpg: requesting key 94558F59 from hkp server keyserver.ubuntu.com
gpg: key 94558F59: public key "Spotify Public Repository Signing Key <operations@spotify.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

After that’s done I checked the expiration date of the new public key and all was well.

daniel@workstation3:~$ sudo apt-key list | grep -B 1 "spotify"
pub   2048R/94558F59 2012-06-25 [expires: 2015-06-25]
uid                  Spotify Public Repository Signing Key <operations@spotify.com>

Hopefully this helped somebody with this issue 🙂