WsL ' Unknown error executing apt-key'

WsL was OK before , including LAMP installation.
Is there an easy solution ?

Update the time on your device. It’s saying there are signature issues which can be caused by the time on your computer being incorrect

Updated the time.
The error is not going away…
Looking forward to an early trial release of WOA for Pi4b-(4) .

root@DESKTOP-1PO3PH6:~# date
Sun Jun 30 19:55:18 DST 2019
root@DESKTOP-1PO3PH6:~# apt update
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:3 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Ign:5 http://download.opensuse.org/repositories/home:/strycore/xUbuntu_18.04 InRelease
Get:6 http://deb.playonlinux.com trusty InRelease [2,590 B]
Get:7 http://deb.debian.org/debian stretch Release [118 kB]
Get:4 http://ftp.debian.org/debian stretch-backports InRelease [91.8 kB]
Get:8 http://download.opensuse.org/repositories/home:/strycore/xUbuntu_18.04 Release [981 B]
Get:9 http://deb.debian.org/debian stretch Release.gpg [2,434 B]
Get:10 http://download.opensuse.org/repositories/home:/strycore/xUbuntu_18.04 Release.gpg [481 B]
Err:2 http://deb.debian.org/debian stretch-updates InRelease
Unknown error executing apt-key
Err:3 http://security.debian.org/debian-security stretch/updates InRelease
Unknown error executing apt-key
Err:6 http://deb.playonlinux.com trusty InRelease
Unknown error executing apt-key
Err:4 http://ftp.debian.org/debian stretch-backports InRelease
Unknown error executing apt-key
Ign:9 http://deb.debian.org/debian stretch Release.gpg
Ign:10 http://download.opensuse.org/repositories/home:/strycore/xUbuntu_18.04 Release.gpg
Reading package lists… Done
W: GPG error: http://deb.debian.org/debian stretch-updates InRelease: Unknown error executing apt-key
E: The repository ‘http://deb.debian.org/debian stretch-updates 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.
W: GPG error: http://security.debian.org/debian-security stretch/updates InRelease: Unknown error executing apt-key
E: The repository ‘http://security.debian.org/debian-security stretch/updates 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.
W: GPG error: http://deb.playonlinux.com trusty InRelease: Unknown error executing apt-key
E: The repository ‘http://deb.playonlinux.com trusty 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.
W: GPG error: http://ftp.debian.org/debian stretch-backports InRelease: Unknown error executing apt-key
E: The repository ‘http://ftp.debian.org/debian stretch-backports 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.
W: GPG error: http://deb.debian.org/debian stretch Release: Unknown error executing apt-key
E: The repository ‘http://deb.debian.org/debian stretch Release’ 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.
W: GPG error: http://download.opensuse.org/repositories/home:/strycore/xUbuntu_18.04 Release: Unknown error executing apt-key
E: The repository ‘http://download.opensuse.org/repositories/home:/strycore/xUbuntu_18.04 Release’ 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.
root@DESKTOP-1PO3PH6:~#

I just hit the same problem. I found that the root cause is that lots of package metadata is missing in WSL on WoA. This means that we don’t have gpg, which means that apt-key does not work since it relies on calling gpg and this means that apt-get cannot verify packagesapt. A somewhat insecure way but still a workaround I found was this:

apt-get --allow-insecure-repositories update
apt-get --allow-unauthenticated -y upgrade

This upgrades installed packages. It is also possible to use “apt-get install” together with --allow-unauthenticated switch. After having installed gpg package, I found that apt-key no longer complains about missing gpg, but it still does not find any keys. The apt-key list command returns no keys. But the keys seem to be installed in /etc/apt/trusted.gpg.d, so something is still wrong somewhere.

After some more digging around. The root cause is obviously dirmngr. When run, dirmngr almost immediately crashes with an “Illegal instruction” error. I assume it was not built for running on this kind of ARM CPUs. The problem is that this causes gpg to fail, which causes apt-key to fail which in turn causes apt-get to fail. Not sure if there is any ARM64 build around of dirmngr that works on the Raspberry Pi CPU.