Score:0

Cannot import GPG keys via apt-key

ug flag

I'm trying to install mono on my Ubuntu 20.04 server.

I followed the official install instructions on: https://www.mono-project.com/download/stable/

When executing:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

the following error is raised:

Executing: /tmp/apt-key-gpghome.l2rhGqvMmi/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: keyserver receive failed: No such file or directory

In similar questions, I saw that more insights could be drawn from running strace. So here is the output for strace. I had to cut some of the intermediate output, to match the post character limit:

execve("/usr/bin/apt-key", ["apt-key", "adv", "--keyserver", "hkp://keyserver.ubuntu.com:80", "--recv-keys", "3FA7E0328081BFF6A14DA29AA6A19B38"...], 0x7ffc2afa5c18 /* 13 vars */) = 0
brk(NULL)                               = 0x55e6a789c000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc1557cd50) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=63853, ...}) = 0
mmap(NULL, 63853, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1cd10ad000
close(3)                                = 0
[...]
read(3, "/etc/apt/trusted.gpg.d/ubuntu-ke"..., 128) = 55
read(3, "", 128)                        = 0
close(3)                                = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19223
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19223, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 19223
openat(AT_FDCWD, "/tmp/apt-key-gpghome.nBHDrgCJ0q/pubring.gpg", O_WRONLY|O_CREAT|O_APPEND, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19224
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19224
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19224, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 19224
dup2(11, 1)                             = 1
close(11)                               = 0
wait4(-1, 0x7ffc1557bfac, WNOHANG, NULL) = -1 ECHILD (No child processes)
faccessat(AT_FDCWD, "/tmp/apt-key-gpghome.nBHDrgCJ0q/pubring.gpg", R_OK) = 0
stat("/usr/local/sbin/cp", 0x7ffc1557c600) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/cp", 0x7ffc1557c600) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/cp", 0x7ffc1557c600)    = -1 ENOENT (No such file or directory)
stat("/usr/bin/cp", {st_mode=S_IFREG|0755, st_size=153976, ...}) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19225
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19225
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19225, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 19225
pipe([3, 4])                            = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19226
close(4)                                = 0
read(3, "/tmp/apt-key-gpghome.nBHDrgCJ0q/"..., 128) = 41
read(3, "", 128)                        = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19226, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 0
close(3)                                = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19226
pipe([3, 4])                            = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19229
close(4)                                = 0
read(3, "/tmp/apt-key-gpghome.nBHDrgCJ0q/"..., 128) = 44
read(3, "", 128)                        = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19229, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 0
close(3)                                = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19229
openat(AT_FDCWD, "/tmp/apt-key-gpghome.nBHDrgCJ0q/gpg.1.sh", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
write(1, "#!/bin/sh\nexec sh '/tmp/apt-key-"..., 122) = 122
dup2(11, 1)                             = 1
close(11)                               = 0
write(1, "Executing: /tmp/apt-key-gpghome."..., 147Executing: /tmp/apt-key-gpghome.nBHDrgCJ0q/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
) = 147
stat("/usr/local/sbin/sh", 0x7ffc1557c700) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/sh", 0x7ffc1557c700) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/sh", 0x7ffc1557c700)    = -1 ENOENT (No such file or directory)
stat("/usr/bin/sh", {st_mode=S_IFREG|0755, st_size=129816, ...}) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19232
wait4(-1, gpg: keyserver receive failed: No such file or directory
[{WIFEXITED(s) && WEXITSTATUS(s) == 2}], 0, NULL) = 19232
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19232, si_uid=0, si_status=2, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 19232
wait4(-1, 0x7ffc1557c59c, WNOHANG, NULL) = -1 ECHILD (No child processes)
stat("/tmp/apt-key-gpghome.nBHDrgCJ0q/aptwarnings.log", 0x7ffc1557c4d0) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "gpgconf", X_OK)    = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/usr/local/sbin/gpgconf", X_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/usr/local/bin/gpgconf", X_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/usr/sbin/gpgconf", X_OK) = -1 ENOENT (No such file or directory)
faccessat(AT_FDCWD, "/usr/bin/gpgconf", X_OK) = 0
openat(AT_FDCWD, "/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(1, 2)                              = 2
stat("/usr/local/sbin/gpgconf", 0x7ffc1557c660) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/gpgconf", 0x7ffc1557c660) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/gpgconf", 0x7ffc1557c660) = -1 ENOENT (No such file or directory)
stat("/usr/bin/gpgconf", {st_mode=S_IFREG|0755, st_size=178848, ...}) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19237
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19237
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19237, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 19237
dup2(11, 1)                             = 1
close(11)                               = 0
dup2(12, 2)                             = 2
close(12)                               = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1cd10ac850) = 19242
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 19242
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19242, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
rt_sigreturn({mask=[]})                 = 19242
wait4(-1, 0x7ffc1557c83c, WNOHANG, NULL) = -1 ECHILD (No child processes)
exit_group(2)                           = ?
+++ exited with 2 +++

I would appreciate any help. If I should provide additional info, I'm happy to do so. Thank you.

Score:0
ug flag

I've resolved the problem.

apt-key adv, basically tells GnuPG to download the keys from the server. First, I thought the keys didn't exist, since a search via the web interface turned out negative. But when prepending 0x to the key, it is found. The issue is known.

Then I directly called gpg to download the keys via:

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

That also failed, with the same error message. I then found an Arch Linux BBS thread, which described the same issue. Their solution was to fix the /etc/resolve.conf file. And indeed, this also helped me (apparently my systemd-resolved.service was failing).

Would have been much easier, if the error message was more helpful. But, ok. I guess it's my fault for not setting up DNS properly.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.