8

I recently installed Ubuntu 17.04 and I'm not able to add any ppa.
I tried to manually add keys using different keyservers but on every attempt I'm getting keyserver received error:

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0F164EEB

Error Received:

Executing: /tmp/apt-key-gpghome.qm2WNA0lTK/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0F164EEB
gpg: keyserver receive failed: No keyserver available

$ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 0F164EEB

Error Received:

Executing: /tmp/apt-key-gpghome.O681PzEx7r/gpg.1.sh --keyserver keys.gnupg.net --recv-keys 0F164EEB
gpg: keyserver receive failed: Connection refused

It is the same case with other keys. I'm not able to add any PPA.

  • Are you behind a firewall that might reject this protocol or that might require you to configure a proxy? – Gilles Apr 27 '17 at 21:47
  • I m using a proxy but it gave the same result even when adding -E flag so I don't think that is the issue here – pearlstar Apr 28 '17 at 7:33
  • 2
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys XX works for me, but it does not work without protocol part hkp://. – mvw Mar 19 at 9:46
7

This also happened to me when something was wrong with the DNS resolution setup. Check that there are nameservers listed in /etc/resolv.conf (also, try alternative nameservers). If you are using systemd-resolved, then make sure that /etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf.

6

I was getting the same 'gpg keyserver connection refused' error with gpg at the command line, GPA, and KGpg. I am using gnupg 2.1.18-8 on Debian Sid. I enabled debugging in dirmngr as follows:

sudo pkill dirmngr; dirmngr --debug-all --daemon --standard-resolver

The debugging output on the console complained about the lack of a Tor connection. It turned out that "use-tor" was enabled in $HOME/.gnupg/dirmngr. (Thanks, gpgconf!) I commented it out, leaving an empty dirmngr.conf, and keyserver communications are now working normally.

3

This error can also be caused if you retrieve gpg keys through tor & tor is not running.

In your system log you will see:

command 'KS_GET' failed: No keyserver available

To retrieve keys through tor set in ~/.gnupg/dirmngr.conf:

# https://gnupg.org/blog/20151224-gnupg-in-november-and-december.html
use-tor
keyserver hkp://jirk5u4osbsr34t5.onion

# https://sks-keyservers.net/overview-of-pools.php#pool_hkps
hkp-cacert /etc/ssl/CA/sks-keyservers.netCA.pem
1

For your information, I've encountered the same problem:

gpg: keyserver receive failed: Connection refused

My resolv.conf contained:

nameserver 127.0.0.1
nameserver XXX.XXX.XXX.XXX
search XXX.XXX

and was immutable:

$ lsattr /etc/resolv.conf
----i---------e---- /etc/resolv.conf

Furthermore, I didn't have a DNS server bound to the loopback network interface (127.0.0.1).

So, when I tried to execute this command

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXXXXXX

apt-key only used the first nameserver that doesn't exist and failed.

I removed the immutability:

sudo chattr -i /etc/resolv.conf

I modified the first nameserver to point to a working one.

And I put the immutability back:

sudo chattr -i /etc/resolv.conf

And finally apt-key worked.

1

SOLUTION(?): Getting same "no keyserver available" error on Parrot Security 3.6.

Used GPA v0.9.10 (Gnu Privacy Assistant).

  1. Click "Server" -> "Retrieve Keys"
  2. Enter , in your case 0F164EEB.
  3. Click "OK". Wait a bit.

If it works, you will have an entry in the "Key Manager" listing. I was able to continue with verification process from there.

0

one of the cause is indeed a proxy issue see Unable to add gpg key with apt-key behind a proxy

you would have to use the following command:

$ sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --keyserver-options http-proxy=http://myproxy:3128 --recv-keys 0F164EEB

...or a combination of curl+apt-key

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.