47

This error has arise when I add gns repository and try to use this command:

#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F88F6D313016330404F710FC9A2FD067A2E3EF7B

the error is:

gpg: keyserver receive failed: Server indicated a failure
1
  • as I've explained in my answer and comment to the downvotes, it's related to DNS and the way that dirmngr in version 2.1.6 did reverse DNS that have been removed in version 2.1.8 I recall, but 2.2.x I've installed from Debian testing/unstable (Debian 9 current as at writing this) also fixed this issue.
    – Hvisage
    Feb 4, 2018 at 15:52

13 Answers 13

72

Behind a firewall you should use the port 80 instead of the default port 11371 :

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9A2FD067A2E3EF7B

Sample output:

Executing: /tmp/apt-key-gpghome.mTGQWBR2AG/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9A2FD067A2E3EF7B
gpg: key 9A2FD067A2E3EF7B: "Launchpad PPA for GNS3" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1
3
  • Not port 11371 or 80 related behind firewall. seems to be rather related to DNS resolution when you start to google the net... ``` Executing: /tmp/apt-key-gpghome.imkAGGXMO8/gpg.1.sh --receive-keys --debug-all -vvv --keyserver hkp://sks1.cryptokeys.org.za:80 gpg: DBG: chan_3 -> KEYSERVER --clear hkp://sks1.cryptokeys.org.za:80 gpg: DBG: chan_3 <- OK gpg: DBG: chan_3 -> KS_GET -- 0x9C1384B1168FD423 gpg: DBG: chan_3 <- ERR 167772379 Server indicated a failure <Dirmngr>```
    – Hvisage
    Feb 1, 2018 at 15:40
  • 17
    I get the same error using dirmngr 2.2.5, and adding hkp:// and :80 resolved the issue
    – lofidevops
    Apr 11, 2018 at 15:25
  • I'm not behind a firewall and am getting this error Jan 29 at 10:35
13

This issue was really tough for me; none of the proposed solutions worked for me until I found this post on reddit. I just went and added this line to /etc/resolv.conf

nameserver 8.8.8.8 # Google dns

you can try any other DNS and see which one works for you.

2
  • This doesn't seem to work unless the first nameserver in the list is functional. Most DNS activity will failover to the next resolver, but this wouldn't for some reason. Oct 11, 2020 at 19:19
  • nameserver 1.1.1.1 is a better option
    – pouya
    Nov 4, 2021 at 23:03
8

It has to do with DNS and what your DNS server does or does return for dirmngr ;( It got introduce since 2.1.16 with dirmngr, and I've been looking for solution myself on 2.1.6 with Debian's default packages. ;(

The correct answer, is: Upgrade to version 2.2.x or later that fixed this problem first time.

5
  • @StephenKitt it wasn't a different answer, I gave the reason why it broke, as the other answer was a totally inadequate answer with all the wrong reasons why it was failing after I've investigated the 2.1.6 versions on Debian. There wasn't any real other fix than to get the latest version from a testing/unstable branch to get passed this problem, which was not HTTP/firewall related, but the DNS issue
    – Hvisage
    Feb 4, 2018 at 15:50
  • Sorry, the comment above is a canned comment which wasn’t quite appropriate. Your edited answer does indeed answer the question, thanks. Feb 4, 2018 at 16:02
  • 3
    a temporary workaround: ping the server (ping keyserver.ubuntu.com) to get its IP number and use this number instead of keyserver.ubuntu.com in your command Nov 27, 2020 at 19:58
  • Relevant bugfix in 2.2+ dev.gnupg.org/T3374 Apr 25, 2021 at 20:56
  • @XavrasWyzryn Thank you, this comment helped me identify a server that is no longer operational, which is why I was getting the error.
    – semitones
    Apr 18 at 19:45
4

Encountered the same issue on ubuntu 18.04, running dirmngr 2.2.4. I went with the option of checking my dns settings and added my local dns server 'nameserver 1.1.1.1' and google's 'nameserver 8.8.8.8'. Then it worked.

3
  • Specifying explicit DNS servers in my network config solved it for me. Gentoo, using NetworkManager.
    – Pistos
    Dec 28, 2018 at 22:55
  • Also remember Quad9 (9.9.9.9) for helping to filter out malware/etc. in a privacy-advocacy manner ;)
    – Hvisage
    Dec 31, 2018 at 10:14
  • Where add??? I just switched to dns 1.1.1.1 and am getting this issue Aug 20, 2019 at 13:06
4

Add 0x before key, so that it turns 0xF88F6D313016330404F710FC9A2FD067A2E3EF7B.

This plus GAD3R's answer solved it for me.

2
  • damn, you're right! i would have never imagined that the missing 0x will not only make it fail, but also lead to such a cryptic message... thanks! Nov 23, 2020 at 20:31
  • 2
    I think you'll find that the 0x is purely a placebo fix. Oct 15, 2021 at 7:59
3

This problem can be caused (as I just experienced it) by an empty resolv.conf as may be the case on a system using systemd-resolved for its primary DNS resolution via nsswitch.

I assume that it's a case of gpg not using nsswitch and the associated libc functions and instead, for some reason, reading resolv.conf itself.

Symptoms:

  • gpg: keyserver receive failed: Server indicated a failure

  • /etc/resolv.conf is empty but hostname resolution e.g. getent hosts google.com, ping google.com etc is fine. Note that dig, drill, nslookup all read resolv.conf directly, so these may not work.

  • /etc/nsswitch.conf has something like hosts: files mymachines myhostname resolve [!UNAVAIL=return] dns in it, where resolve is a module provided by systemd (see man 8 libnss_resolve.so.2 for details).

Resolution:

You want to make a symbolic link to systemd's autogenerated resolv.conf that reflects the current resolver settings. I suggest reading man 8 systemd-resolved, section "/ETC/RESOLV.CONF" for details on what this does, exactly.

$ # you should check this has reasonable contents before using it
$ cat /run/systemd/resolve/stub-resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

# rm /etc/resolv.conf
# ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
1
  • Thank you, this issue was driving me nuts!
    – nenchev
    May 2 at 13:36
2

Usually when you have a non default DNS configuration in your system, for example if you're using dnsmasq or another DNS service, other than systemd-resolve, it's possible that dirmngr used by gpg fails to get the resolved name for keyserver.ubuntu.com, then, you need to check your name resolution software.

In my case, I have installed dnsmasq for name resolution in a Zimbra mail server. In this case it is important that you prevent that the resolvconf software controls dnsmasq, this is editing the /etc/default/dnsmasq file and uncommenting this line: IGNORE_RESOLVCONF=yes. Then you have to restart the dnsmasq and try to resolve with the local dns server with this command:

:~$ host -v keyserver.ubuntu.com 127.0.0.1

If it is ok, you will see something like this:

Trying "keyserver.ubuntu.com"
Using domain server:
Name: 127.0.0.1
Address: 127.0.0.1#53
Aliases: 

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13994
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;keyserver.ubuntu.com.      IN  A

;; ANSWER SECTION:
keyserver.ubuntu.com.   417 IN  A   162.213.33.8
keyserver.ubuntu.com.   417 IN  A   162.213.33.9

Received 70 bytes from 127.0.0.1#53 in 14 ms
Trying "keyserver.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33907
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;keyserver.ubuntu.com.      IN  AAAA

Received 38 bytes from 127.0.0.1#53 in 1 ms
Trying "keyserver.ubuntu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45211
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;keyserver.ubuntu.com.      IN  MX

;; AUTHORITY SECTION:
ubuntu.com.     1748    IN  SOA ns1.canonical.com. hostmaster.canonical.com. 2018053167 10800 3600 604800 3600

Received 99 bytes from 127.0.0.1#53 in 16 ms

Even if you're not using some DNS server, try to ask to systemd-resolve if it can resolve the URL with this:

:~$ host -v keyserver.ubuntu.com 127.0.0.53

If not, let us know what you get.

2

I was getting this error on when I tried to access a key.

gpg: keyserver receive failed: No dirmngr

Killing dirmngr and running the command again solved it for me, like below:

gpgconf --kill dirmngr

It is worth a try, let me know if it works.

1
1

If you are living in Belarus, than you need to know that gpg issue may be cased by new buggy state firewall. Today state firewall in Belarus may block hkps using DPI for you. It is actually a bug: you can report it directly to firewall managers if you think this organization will change something.

If you want your hkps (and hkp too) back, than you have to follow complete china users firewall experience:

  1. remote openvpn server in normal country.
  2. obfs4proxy server (not required for now).
  3. stunnel server.
  4. frontend domain (azure) (not required for now).
  5. stunnel client.
  6. obfs4proxy client (not required for now).
  7. openvpn client.

See also gentoo issue.

1
  • I am in Russia, and we have the same issue nowadays. (We are lagging behind by a few months only in the thickness of our firewall.) -- I had to bypass getting the keys by using the #apt-get --allow-unauthenticated, as in my answer below. All the best in surviving...
    – Maxim
    Dec 27, 2021 at 7:26
0

This also works to remove the DNS issue:

sudo apt-key adv --keyserver $( dig +short keyserver.ubuntu.com | head -n1 ) \
                 --recv-keys 42670A7FE4D0441C8E4632349E4FDC074A4EF02D
0

Sharing my 2 days of troubleshooting: Symptoms:

  • gpg: keyserver receive failed: Server indicated a failure
  • /etc/resolv.conf is using stub 127.0.0.53 but resolves hostname fine (ie. getent hosts google.com work as expected)
  • more than 1 ethernet adapter that is up

Troubleshoot:

  • open another terminal and execute journalctl -u systemd-resolved -f
  • in the first terminal do systemctl edit systemd-resolved

paste

 [Service]
 Environment=SYSTEMD_LOG_LEVEL=debug

restart

systemctl restart systemd-resolve<br/> sudo apt-key adv --keyserver
keyserver.ubuntu.com --recv-keys
F88F6D313016330404F710FC9A2FD067A2E3EF7B

check in the auxiliary terminal, the adapter it is using and the fail to be sure that this the cause, just set down the ethernet adapter and repeat the key request if, it works now, you may understand that the adapter do not have a satisfactory name server;

adding 8.8.8.8 to the netplan config of the 1st adapter will solve the problem

0

I live in a totalitarian country* with thick firewall, and neither adding :80 nor editing resov.conf helped

I was forced to use #apt-get --allow-unauthenticated to bypass getting the keys...

*Russia

-2

Some of the issues that can lead to problem are: 1- You are behind the firewall, 2- You are using proxy settings I changed the network from WIFI to my mobile which along with below mentioned address actually solved my problem, sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

2
  • 1
    Asking for a different key isn’t going to make a difference here. Feb 10 at 10:26
  • 2
    Indeed; they attempted to receive F88F6D313016330404F710FC9A2FD067A2E3EF7B but got an error. How is retrieving this C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 key going to help? Note also that this question has an accepted answer that indicates their problem was solved with "you should use the port 80 instead of the default port 11371".
    – Jeff Schaller
    Feb 10 at 13:23

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.