-1

I'm using kali wsl(version 1) on Windows 10, and I installed it on non-C drive with this method here.

This is the return of uname -r: 4.4.0-19041-Microsoft

I got this error while apt update:

user@host:~$ sudo apt update
[sudo] password for user:
Get:1 <mirror_site> kali-rolling InRelease [30.5 kB]
Err:1 <mirror_site> kali-rolling InRelease
  The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository <[email protected]>
Fetched 30.5 kB in 2s (12.5 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: <mirror_site> kali-rolling InRelease: The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository <[email protected]>
W: Failed to fetch http://http.kali.org/kali/dists/kali-rolling/InRelease  The following signatures were invalid: EXPKEYSIG ED444FF07D8D0BF6 Kali Linux Repository <[email protected]>
W: Some index files failed to download. They have been ignored, or old ones used instead.

Then I tried fix this with gpg --keyserver hkp://keys.gnupg.net --recv-key 7D8D0BF6, got this error:

E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation

So, I tried install gnupg_2.2.27-2_all.deb manually from Debian Package. However, there's more dependency problems appeared.

user@host:~$ sudo dpkg -i gnupg_2.2.27-2_all.deb
(Reading database ... 17159 files and directories currently installed.)
Preparing to unpack gnupg_2.2.27-2_all.deb ...
Unpacking gnupg (2.2.27-2) over (2.2.27-2) ...
dpkg: dependency problems prevent configuration of gnupg:
 gnupg depends on dirmngr (<< 2.2.27-2.1~); however:
  Package dirmngr is not installed.
 gnupg depends on dirmngr (>= 2.2.27-2); however:
  Package dirmngr is not installed.
 gnupg depends on gnupg-l10n (= 2.2.27-2); however:
  Package gnupg-l10n is not installed.
 gnupg depends on gnupg-utils (<< 2.2.27-2.1~); however:
  Package gnupg-utils is not installed.
 gnupg depends on gnupg-utils (>= 2.2.27-2); however:
  Package gnupg-utils is not installed.
 gnupg depends on gpg (<< 2.2.27-2.1~); however:
  Package gpg is not installed.
 gnupg depends on gpg (>= 2.2.27-2); however:
  Package gpg is not installed.
 gnupg depends on gpg-agent (<< 2.2.27-2.1~); however:
  Package gpg-agent is not installed.
 gnupg depends on gpg-agent (>= 2.2.27-2); however:
  Package gpg-agent is not installed.
 gnupg depends on gpg-wks-client (<< 2.2.27-2.1~); however:
  Package gpg-wks-client is not installed.
 gnupg depends on gpg-wks-client (>= 2.2.27-2); however:
  Package gpg-wks-client is not installed.
 gnupg depends on gpg-wks-server (<< 2.2.27-2.1~); however:
  Package gpg-wks-server is not installed.
 gnupg depends on gpg-wks-server (>= 2.2.27-2); however:
  Package gpg-wks-server is not installed.
 gnupg depends on gpgsm (<< 2.2.27-2.1~); however:
  Package gpgsm is not installed.
 gnupg depends on gpgsm (>= 2.2.27-2); however:
  Package gpgsm is not installed.
 gnupg depends on gpgv (>= 2.2.27-2); however:
  Version of gpgv on system is 2.2.12-1.

dpkg: error processing package gnupg (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 gnupg

I don't know what to do next after this. do I really need to download and install all these dependency manually? What I gotta do to make apt works?

5
  • I dont know much about WSL but if they're using kernel version 4.4.0 thats ancient Commented Aug 24, 2021 at 15:00
  • @dcom-launch Not that it really matters, since WSL1 didn't use a "real" Linux kernel anyway -- It just attempted to map Linux kernel APIs to Windows kernel APIs (and did a pretty good job of it, given that challenge). WSL2's kernel is a real Linux kernel running under virtualization and is regularly updated by Microsoft. The last I saw, it was at 5.10.16 (probably newer by now) in the newer WSL releases coming in Windows 11. Commented Aug 24, 2021 at 19:00
  • This turns out to be primarily a problem with the Microsoft docs on the topic, but you couldn't have known this in advance. That said, since you found the instructions on Super User, it might have been better to post this question there. Again, you really couldn't have known that it wasn't a Kali issue, though. Commented Aug 24, 2021 at 21:06
  • @NotTheDr01ds I wasn't sure it was an out-dated release, and thought the wsl release of kali might be different from the bare-metaled one. So I created the question here, sorry about that.
    – Hugo
    Commented Aug 26, 2021 at 14:33
  • @Hugo Oh no worries -- If it were really off-topic here, I would have asked you to move it over before I answered. It's a good question, and I appreciate you adding in the critical information about it being manually installed. It was the key to solving this. Another user posted the same problem about a month ago, but without the information about it being manually installed, I didn't "connect-the-dots". Commented Aug 26, 2021 at 20:11

2 Answers 2

1

Well, sorry you had to go through such a complicated process, but I just found a much simpler solution. Hopefully this will save someone else some time if they come across it in the future.

To update the keyring:

> wget https://http.kali.org/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2020.2_all.deb
> sudo dpkg -i kali-archive-keyring_2020.2_all.deb

You should then be able to sudo apt update && sudo apt upgrade normally.

Courtesy u/desktopecho on Reddit and the referenced Github repo.

5
  • Not at all. I know a new way to access files downloaded by Microsoft Store after your previous answer, since I don't know much about cmd or powershell. :-)
    – Hugo
    Commented Sep 15, 2021 at 1:59
  • And I downloaded a new copy of kali wsl 2019, it login my old kali wsl profile automatically without install procedure. I remember that there's a way to pass this. I'll be back with reproduce result of mine later in case someone need this.
    – Hugo
    Commented Sep 15, 2021 at 2:09
  • Sorry for replying so late, I changed a new hard drive and upgraded to 21H1 recently. This method works on my device.
    – Hugo
    Commented Sep 28, 2021 at 8:29
  • @Hugo Glad it saved you the time the second time around, at least :-) Commented Sep 28, 2021 at 9:59
  • 1
    Thanks for this tip. The current file is kali-archive-keyring_2022.1_all.deb at the same path and works great in 2023, even without gnupg (for apt-key support) and with ancient CA root certs that don't let it fetch the package indices via HTTPS because of expired/untrusted cert chains.
    – bburhans
    Commented Oct 8, 2023 at 18:48
0

This appears to be due to an outdated link in the Microsoft docs for installing distributions manually. The Kali package linked to there is 2019.2, and I can reproduce the problem you are experiencing with that (outdated) package. There's certainly a later Kali WSL package available, because the version installed from the Microsoft Store is 2021.2. Unfortunately, I do not know the direct link to that package. I've submitted this as an issue on the MicrosoftDocs\WSL Github.

The problem is further compounded by the fact that Kali provided for WSL is a very minimal distribution and doesn't include some of the tools, such as GPG, that would be provided in a "normal" distribution. So the instructions you would normally follow for updating the keys don't work on WSL.

Perhaps there's a way to get gpg installed with all its dependencies without a working apt, but in my opinion it's not worth it.

Instead, let me propose an alternative installation method, with the understanding that you need to install on a drive other than C:. That said, you're going to need to temporarily dedicate (or free up) a little under 1GB on the C: drive during this process. We can free it up at the end.

Please don't let the length of the instructions below scare you. I tend to be overly detailed to make sure you understand what is going on, and to try to make it as failproof as possible. I have tested the entire process below personally, but let me know if you run into any trouble.

  • First, remove the existing Kali installation. I'm assuming that you don't have any critical files there, since I'm guessing you recently installed. But if you do, move them out of the WSL instance.

    Then, from PowerShell or CMD:

    wsl --unregister kali-linux
    
  • Also delete the (old, outdated) package files you downloaded previously.

  • Next, go to the Microsoft Store and install Kali. This is going to install the package files under the protected C:\Program Files\WindowsApps\ directory, which is why we temporarily need space on that drive.

  • Assuming you are running Windows Terminal, run Start-Process wt -Verb RunAs in PowerShell to get an admin prompt. If not Windows Terminal, run PowerShell as Admin.

  • In the Admin PowerShell, run Get-ChildItem -Recurse 'C:\Program Files\WindowsApps\Kali*' | Where-Object {$_.Name -eq 'install.tar.gz' } | % { $_.DirectoryName } | Set-Clipboard to get the directory where the Kali package was installed.

  • Confirm that it found the right path via Get-Clipboard. It should return something like C:\Program Files\WindowsApps\KaliLinux.54290C8133FEE_1.8.0.0_x64__ey8k8hqnwqnmg. This path may change in the future (if you are reading this answer later), but that's okay.

  • Exit the Admin Shell and return to your "normal user" PowerShell:

    mkdir D:\wsl\instances\kali-linux
    cd D:\wsl\instances\kali-linux
    Get-Clipboard # Confirm that the Kali package path is still on the clipboard
    Copy-Item "$(Get-Clipboard)\*"
    

    This will copy the package files over to the D: drive. Of course, you can set the installation path however you want. I personally use a wsl\instances\distro-name format since I keep multiple distributions and instances around. I recommend it for future-proofing in case you want more copies later.

  • You should now have a number of files in the destination directory. Something like:

    Name
    ----
    AppxBlockMap.xml
    AppxManifest.xml
    AppxMetadata/
    AppxSignature.p7x
    Assets/
    install.tar.gz
    kali.exe
    resources.pri
    
  • From here, you should be back in familiar territory. Just run .\kali.exe, wait a few moments, set your username and password, and WSL will launch into Kali.

  • Exit Kali and (back in PowerShell) remove the package files from that directory with Remove-Item Appx*, Assets, install.tar.gz, resources.pri.

  • For WSL1, you should end up with:

    • A rootfs directory, where the filesystem is stored. IMPORTANT: Do NOT access this for any reason from Windows/PowerShell/CMD/Notepad/Any other Windows App, etc. There be dragons.
    • A temp directory
    • fsserver
    • And the kali.exe command that we copied over (but didn't delete). It's not all that useful, IMHO, but you might want it. It can be used to launch Kali, but the wsl command is much better (more features, better supported).
  • Uninstall Kali from the Microsoft Store to reclaim your space on the C: drive.

Your installation should be the latest and greatest available from Kali in the Microsoft Store. You can check the Kali release with cat /etc/os-release. At present, this is 2021.2. sudo apt update && sudo apt upgrade should now work just fine ...

1
  • 1
    Thanks bro, just finished these procedure and problem solved!
    – Hugo
    Commented Aug 26, 2021 at 14:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .