17

I have two machines; a desktop and a laptop. The desktop runs WSL2 and an OpenSSH server on the Windows side. I'm able to connect to the SSH server from the laptop without any problems but not able to start WSL over the SSH connection. When I run wsl or bash the following message prints: The file cannot be accessed by the system. Note that I can start WSL from the terminal directly on the desktop (but not if I SSH into the desktop from the desktop).

This is so weird, I have no idea what could be the problem. I have tried searching for a similar problem but haven't found anything.

Isak
  • 295
  • 2
  • 6

2 Answers2

21

This is likely because you have installed the "Windows Subsystem for Linux" that is available in the Microsoft Store. This is a known issue.

Update note: Although this has been listed as a "Known issue" of the Store/App version since it was first available, the WSL team recently (November 29, 2022) created issue #9231 to track this, with a comment in December from the dev lead mentioning that they are working on a solution.


I think this may be a limitation with all apps installed from the Store, but with Windows 11's ability to install non-UWP apps from the Store, I'm not sure. It may require a Windows update to resolve it -- It doesn't seem that the WSL team has been able to fix it on their own so far, at least.

Unfortunately the only solution for now is to remain on an older (now much older) version of WSL. If you do need the ability to launch WSL from within SSH, uninstall the Preview version and then re-install with wsl --install --inbox. Without --inbox, new Windows 10 and 11 versions will now install the Store version.

NotTheDr01ds
  • 17,574
  • 4
  • 44
  • 81
  • 1
    Would never have thought that the preview version would be the problem. Uninstalled it and everything works now. It did prompt me to update to it again in the terminal but guess I'll have to wait for them to fix this. Thanks for the quick help! – Isak Apr 06 '22 at 02:06
  • @Isak Excellent - Glad I could help! – NotTheDr01ds Apr 06 '22 at 02:36
  • 3
    This actually does work, tested with Windows 11 21H2. Re-installing wsl is a tad harder, there is no `wsl --install --inbox` command, but after uninstalling wsl you can visit https://aka.ms/wsl2kernel and install the provided update. I'm not sure if this played a part, but I also installed a non-store version of Ubuntu from the instructions "Downloading distributions" (rather than give you a URL that may change, google `If the Microsoft Store app is not available, you can download and manually install Linux distributions`) – Orwellophile Feb 24 '23 at 19:07
9

A solution to still access WSL2 from a remote machine is to set up ssh in wsl and add the client's public key to wsl, and then use the ssh ProxyJump option:

ssh -J <windows_host_username>@<ip_windows_host> <wsl_username>@localhost
DV_33
  • 91
  • 1
  • 2