After update to Ubuntu 18.04 I hit a problem with apt-key that would not fetch keys saying gpg: keyserver receive failed: Invalid argument.
Spotify updated their apt repository signing keys and apt would not update anymore with NO_PUBKEY gpg error.
$ sudo apt update [...] Get:3 http://repository.spotify.com stable InRelease [3,302 B] Err:3 http://repository.spotify.com stable InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A87FF9DF48BF1C90 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 A87FF9DF48BF1C90 E: The repository 'http://repository.spotify.com stable InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
The missing key is A87FF9DF48BF1C90 (0x931FF8E79F0876134EDDBDCCA87FF9DF48BF1C90) and was generated on 2018-05-23.
Yet apt-key fails to fetch it.
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xA87FF9DF48BF1C90 Executing: /tmp/apt-key-gpghome.2KOtbTK3PD/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xA87FF9DF48BF1C90 gpg: keyserver receive failed: Invalid argument
Quick digging shows it’s a problem with gpg/dirmngr itself. It fails with dubious “Invalid argument <Dirmngr>”.
$ sudo gpg -vvv --debug-all --keyserver keyserver.ubuntu.com --recv-keys A87FF9DF48BF1C90 gpg: Note: no default option file '/root/.gnupg/gpg.conf' gpg: using character set 'utf-8' gpg: enabled debug flags: packet mpi crypto filter iobuf memory cache memstat trust hashing ipc clock lookup extprog gpg: DBG: [not enabled in the source] start gpg: DBG: chan_3 <- # Home: /root/.gnupg gpg: DBG: chan_3 <- # Config: [none] gpg: DBG: chan_3 <- OK Dirmngr 2.2.4 at your service gpg: DBG: connection to the dirmngr established gpg: DBG: chan_3 -> GETINFO version gpg: DBG: chan_3 <- D 2.2.4 gpg: DBG: chan_3 <- OK gpg: DBG: chan_3 -> KEYSERVER --clear hkp://keyserver.ubuntu.com gpg: DBG: chan_3 <- OK gpg: DBG: chan_3 -> KS_GET -- 0xA87FF9DF48BF1C90 gpg: DBG: chan_3 <- ERR 167804976 Invalid argument <Dirmngr> gpg: keyserver receive failed: Invalid argument gpg: DBG: chan_3 -> BYE gpg: DBG: [not enabled in the source] stop gpg: keydb: handles=0 locks=0 parse=0 get=0 gpg: build=0 update=0 insert=0 delete=0 gpg: reset=0 found=0 not=0 cache=0 not=0 gpg: kid_not_found_cache: count=0 peak=0 flushes=0 gpg: sig_cache: total=0 cached=0 good=0 bad=0 gpg: random usage: poolsize=600 mixed=0 polls=0/0 added=0/0 outmix=0 getlvl1=0/0 getlvl2=0/0 gpg: rndjent stat: collector=0x0000000000000000 calls=0 bytes=0 gpg: secmem usage: 0/65536 bytes in 0 blocks
As the root cause of this is unknown at the moment I workarounded it by downloading the key with wget and adding it to apt trusted keys manually.
$ wget -q "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xA87FF9DF48BF1C90" -O- | gpg --dearmor > spotify-A87FF9DF48BF1C90.gpg $ sudo mv spotify-A87FF9DF48BF1C90.gpg /etc/apt/trusted.gpg.d/
Apt updated spotify repository correctly.
$ sudo apt update [...] Get:7 http://repository.spotify.com stable InRelease [3,302 B] Get:9 http://repository.spotify.com stable/non-free i386 Packages [1,171 B] Get:10 http://repository.spotify.com stable/non-free amd64 Packages [1,626 B] Fetched 89.3 kB in 1s (81.2 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 1 package can be upgraded. Run 'apt list --upgradable' to see it.
And spotify update is now visible.
$ apt list --upgradable Listing... Done spotify-client/stable 1:220.127.116.110.g51b03ac3-13 amd64 [upgradable from: 1:18.104.22.1688.g758ebd78-41]
Obviously this applies to other keys as well. You can look them up on https://keyserver.ubuntu.com and download/store if needed.