Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start wsl in ssh session. #7900

Open
1 of 2 tasks
Domain opened this issue Jan 7, 2022 · 42 comments
Open
1 of 2 tasks

Cannot start wsl in ssh session. #7900

Domain opened this issue Jan 7, 2022 · 42 comments

Comments

@Domain
Copy link

Domain commented Jan 7, 2022

Version

Microsoft Windows [版本 10.0.22523.1000]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.74.3

Distro Version

Ubuntu 21.10

Other Software

OpenSSH_for_Windows_8.6p1, LibreSSL 3.3.3

Repro Steps

  1. Connect to windows 10 over ssh
  2. type wsl to start

Expected Behavior

wsl start successful

Actual Behavior

Only output: the file cannot be accessed by the system

Diagnostic Logs

No response

@benhillis
Copy link
Member

Are you using the version of WSL from the Microsoft Store?

@benhillis
Copy link
Member

If so, this is a known issue: https://docs.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues

@Domain
Copy link
Author

Domain commented Jan 13, 2022

Are you using the version of WSL from the Microsoft Store?
If so, this is a known issue: https://docs.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues

Oh, yes, I just upgrade to the store version.

@ghost ghost removed the needs-author-feedback label Jan 13, 2022
@ppigazzini
Copy link

I successfully reverted uninstalling from "Apps and Features" the 2 apps WSL and gWSL installed with the Microsoft Store "Windows Subsystem for Linux Preview" (after exporting my distros as backup).

@Domain
Copy link
Author

Domain commented Jan 14, 2022

I successfully reverted uninstalling from "Apps and Features" the 2 apps WSL and gWSL installed with the Microsoft Store "Windows Subsystem for Linux Preview" (after exporting my distros as backup).

👍, thanks for the tips!

@kansson
Copy link

kansson commented Apr 8, 2022

Will this ever be fixed?

@barak14
Copy link

barak14 commented Aug 1, 2022

I would like to be able to use WSL2g when i am using the machine locally and SSH when I need to remote in. It's a better experience than having to RDP into my windows machine to access the WSL filesystem. Is this likely to be fixed?

@zzjin
Copy link

zzjin commented Aug 29, 2022

Uninstall from store version, and install wsl from command line works, but windows 11 will automated upgrade to store version after some update leases.
Any update here to reslove https://docs.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues ?

@Domain
Copy link
Author

Domain commented Sep 22, 2022

Any update on this issue? I need systemd and ssh!

@mg-christian-axelsson
Copy link

I'm running into this issue after upgrading to Win11 22H2

@gurnec
Copy link

gurnec commented Sep 29, 2022

Just to clarify an earlier comment, it's only necessary to remove the Windows Store app to restore SSH capability. After doing a backup with wsl --export, open Start, search for Windows Subsystem for Linux Preview, and select Uninstall from the bottom right.

It's not necessary to remove (or at least it wasn't for me) Windows Subsystem for Linux Update nor Windows Subsystem for Linux WSLg Preview from Apps > Installed Apps.

You can check by running wsl --status. With the Windows Store app installed, it should look similar to:

Default Distribution: Ubuntu
Default Version: 2
WSL version: 0.66.2.0
Kernel version: 5.15.57.1
WSLg version: 1.0.42
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.521

Without it installed:

Default Distribution: Ubuntu
Default Version: 2

Windows Subsystem for Linux was last updated on 3/25/2022
WSL automatic updates are on.

Kernel version: 5.10.102.1

@ddddavid-he
Copy link

I'm running into this issue after upgrading to Win11 22H2

I do too after upgrading to 22H2 and wsl2 kernel 5.15

@kansson
Copy link

kansson commented Nov 8, 2022

Is there some technical limitation why this isn't worked on?

@lxg208
Copy link

lxg208 commented Dec 12, 2022

I need to use the store version for the stick keys bug (microsoft/wslg#899). And I need to ssh into my machine. Can we fix both bugs? It has been more than a year.

@davidleechen
Copy link

Confirming this issue still exists on Windows 11 22H2 22621.1105. I was prompted inside WSL2 to update to the store version, and did so, then lost the ability to ssh. Uninstalling the store version fixed the problem. This was the non-preview GA version.

@Dash
Copy link

Dash commented Jan 31, 2023

Not sure if there is anyway of getting this voted for, so I'll leave a comment.

To run a docker daemon in WSL you need systemd, which as you may have guessed it, needs the store version of WSL to enable. And yep, once that's done you can no longer access WSL via the Windows SSH host.

@mg-christian-axelsson
Copy link

Not sure if there is anyway of getting this voted for, so I'll leave a comment.

To run a docker daemon in WSL you need systemd, which as you may have guessed it, needs the store version of WSL to enable. And yep, once that's done you can no longer access WSL via the Windows SSH host.

You don't need systemd to run daemons. Stick something like

[boot]
command = service docker start

into /etc/wsl.conf and it will work. I'm not arguing that it's more pretty or better than a systemd setup but it gets the job done.

@ndevenish
Copy link

Confirming this issue still exists on Windows 11 22H2 22621.1105. I was prompted inside WSL2 to update to the store version, and did so, then lost the ability to ssh. Uninstalling the store version fixed the problem. This was the non-preview GA version.

Exactly same situation here. I was prompted to upgrade:

Windows Subsystem for Linux is now available in the Microsoft Store!
You can upgrade by running 'wsl.exe --update' or by visiting https://aka.ms/wslstorepage
Installing WSL from the Microsoft Store will give you the latest WSL updates, faster.
For more information please visit https://aka.ms/wslstoreinfo

and this disabled my access.

@Adelrisk
Copy link

My workaround worked as follows:

  1. Remove all subsystems and linux distributions from Apps and Features (aka Store installs)
  2. (Re-)install wsl using the steps for older versions of WSL

I wish you luck 🍀

@shusso
Copy link

shusso commented Feb 25, 2023

My workaround worked as follows:

  1. Remove all subsystems and linux distributions from Apps and Features (aka Store installs)
  2. (Re-)install wsl using the steps for older versions of WSL

I wish you luck 🍀

Confirming that this worked for me. The only difference was that I removed the "Window subsystem for linux" app from the Start Menu.

@andreyrd
Copy link

Any explanation/workaround? Some of us need to use the Store version.

@lxg208
Copy link

lxg208 commented Apr 3, 2023

My workaround worked as follows:

  1. Remove all subsystems and linux distributions from Apps and Features (aka Store installs)
  2. (Re-)install wsl using the steps for older versions of WSL

I wish you luck 🍀

Confirming that this worked for me. The only difference was that I removed the "Window subsystem for linux" app from the Start Menu.

Unfortunately, the preview version solves the sticky key problem for me, the benefit of using preview version outweighs older version. I'm wondering why this fix is not ported back.

For "sticky" issue, see, e.g. #6955

@barak14
Copy link

barak14 commented Apr 4, 2023

I followed this to get SSH working with the preview version, by enabling sshd on WSL2 and Windows: https://www.reddit.com/r/bashonubuntuonwindows/comments/t2x1pc/my_lab_notes_to_configure_ssh_access_into_wsl_1/
Although I think i just start sshd using wsl.conf

ssh config on client PC:

Host wsl
  Hostname localhost
  Port 2022
  User username
  ProxyJump remote-pc
  UserKnownHostsFile ~\.ssh\wsl

ssh config on server:

Host localhost
  User username
  Port 2022
  IdentityFile ~\.ssh\id_rsa

@nick-phillips
Copy link

Just adding that @gurnec's recommendation to remove the Windows Subsystem for Linux app using Add or Remove Programs worked for me. I updated wsl to get systemd support for wsl on Windows 10, didn't realize the headaches it would cause.

Removing the app did not delete my distros, but backing up using wsl --export before uninstalling might be a good idea.

@clxyder
Copy link

clxyder commented Apr 24, 2023

I encountered this issue and removing the update fixed it, but ideally it would be awesome if we could fix this issue.

WSL:

Kernel version: 5.10.60.1

OS:

Edition	Windows 10 Pro
Version	21H2
Installed on	‎9/‎10/‎2020
OS build	19044.2846
Experience	Windows Feature Experience Pack 120.2212.4190.0

@tvkit
Copy link

tvkit commented Jun 5, 2023

On Windows 11. I disabled then reenabled (and rebooted) via Features which did nothing. Also tried the dsim recommendations to no avail. Upthread, someone mentioned the App Store. I found WSL there and Repaired it which worked. Existing containers okay.

@nicholasq
Copy link

a year and a half later after this issue was started and it's still not fixed

@kendofriendo
Copy link

+1 for what tvkit said. I did the "repair" option and it fixed it.

@NotTheDr01ds
Copy link

I believe this is a duplicate of #9231. Yes, technically 9231 is a duplicate of this, since it was created later, but it was the root-issue bug that the WSL team created publicly to track this.

This is now somewhat/mostly fixed in the 2.0.0 pre-release. Running:

C:\Program Files\WSL\wsl.exe

will now work from an SSH session (a.k.a. Session 0).

As mentioned in #9231, the WSL team is still working on enabling this for the "normal" wsl.exe binary.

@xiaoc57
Copy link

xiaoc57 commented Nov 4, 2023

我找到了适合我的解决方案:

  • 卸载“Windows Subsystem for Linux”(商店版本)
  • 通过命令行安装 WSL 请参阅 -> https://learn.microsoft.com/en-us/windows/wsl/install
  • 通过“wsl --update --inbox”更新 WSL
    有了这个,我没有任何问题,并且可以通过 SSH 使用 WSL 中的所有功能。

very nice job

@buvinghausen
Copy link

Same thing cropped up with the 23H2 update. Was able to remove the WSL app and all components then bring it back to life from the command line.

@xiaoc57
Copy link

xiaoc57 commented Dec 10, 2023

我找到了适合我的解决方案:

  • 卸载“Windows Subsystem for Linux”(商店版本)
  • 通过命令行安装 WSL 请参阅 -> https://learn.microsoft.com/en-us/windows/wsl/install
  • 通过“wsl --update --inbox”更新 WSL
    有了这个,我没有任何问题,并且可以通过 SSH 使用 WSL 中的所有功能。

非常好的工作

我找到了适合我的解决方案:

  • 卸载“Windows Subsystem for Linux”(商店版本)
  • 通过命令行安装 WSL 请参阅 -> https://learn.microsoft.com/en-us/windows/wsl/install
  • 通过“wsl --update --inbox”更新 WSL
    有了这个,我没有任何问题,并且可以通过 SSH 使用 WSL 中的所有功能。

very nice job

if you want to use wsl whose version is app store, you should use ProxyJump, the command likes below:
Host openssh_win32
Hostname 192.168.191.52
User xiaoc57

Host openssh_wsl
ProxyJump openssh_win32
User xiaoc57
HostName localhost
Port 2222
the openssh_win32 is your windows, and openssh_wsl may be your ubuntu.
this command need start ssh in both operation system. and need listening 2222 from windows to wsl. maybe my describe is poor , if you have some question ,you can email me [email protected].

@entee28
Copy link

entee28 commented Feb 13, 2024

My workaround worked as follows:

  1. Remove all subsystems and linux distributions from Apps and Features (aka Store installs)
  2. (Re-)install wsl using the steps for older versions of WSL

I wish you luck 🍀

Also confirming that this works for me, many thanks
At the moment of this comment the wsl --install command will install the store version, which makes wsl in ssh session not working.

@tgross35
Copy link

tgross35 commented Feb 29, 2024

This appears to be fixed in a recent version 🎉. After running wsl --update from a GUI session, running wsl.exe in a SSH session correctly launches the Linux interface.

My version after the update is 2.0.14:

C:\Users\tg>wsl --version
WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3155

Executing with the full path C:\Users\username\AppData\Local\Microsoft\WindowsApps\wsl.exe gets the same result, to confirm this is indeed using the Windows Store install.

@mominshaikhdevs
Copy link

This appears to be fixed in a recent version 🎉. After running wsl --update from a GUI session, running wsl.exe in a SSH session correctly launches the Linux interface.

My version after the update is 2.0.14:

C:\Users\tg>wsl --version
WSL version: 2.0.14.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3155

Executing with the full path C:\Users\username\AppData\Local\Microsoft\WindowsApps\wsl.exe gets the same result, to confirm this is indeed using the Windows Store install.

If you can launch the store version of wsl.exe(which is a msix-packaged command line executable) over SSH, Can you also verify that you are able to launch any other MSIX-packaged command line based executable over SSH too?
For example: Julia?

@tgross35
Copy link

tgross35 commented Mar 1, 2024

If you can launch the store version of wsl.exe(which is a msix-packaged command line executable) over SSH, Can you also verify that you are able to launch any other MSIX-packaged command line based executable over SSH too? For example: Julia?

After running winget install julia -s msstore, I am indeed able to launch juliaup and julia over SSH, from the same location.

(I doubt it makes a difference but I am also using Powershell as the default shell for SSH, as described at https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration#configuring-the-default-shell-for-openssh-in-windows. Really that should be the default IMO)

@mominshaikhdevs
Copy link

After running winget install julia -s msstore, I am indeed able to launch juliaup and julia over SSH, from the same location.

wow! the root issue of all the other issues is PowerShell/Win32-OpenSSH#1632 (which is basically, the MSIX-packaged executables that use App Execution Aliases[found in Settings > Apps > Apps & features > App Execution Aliases] inability to be launched over SSH).

seems, that root issue PowerShell/Win32-OpenSSH#1632 has been fixed at last, which is good.

@shihabsararrafid
Copy link

shihabsararrafid commented Mar 6, 2024

On Windows 11. I disabled then reenabled (and rebooted) via Features which did nothing. Also tried the dsim recommendations to no avail. Upthread, someone mentioned the App Store. I found WSL there and Repaired it which worked. Existing containers okay.

Thanks a lot. It worked.

@gtoal
Copy link

gtoal commented Apr 26, 2024

I had the same problem on a Windows 10 system where uninstalling/reinstalling WSL2 was not an option (due to problems with X windows which only works under this one specific configuration).
bash.exe would not run as would not also wsl.exe from \windows\system32, but the wsl.exe from Program Files\WSL at least started but failed because it didn't understand the "-c" parameter passed to it by ssh. So I made a workaround, which was to create a linux.bat file containing:
@"c:\Program Files\WSL\wsl.exe" -- %2 %3 %4 %5 %6 %7 %8
and then setting the default ssh shell to that batch file via PowerShell in admin mode:
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "c:\ProgramData\ssh\linux.bat" -PropertyType String -Force
The "--" in the batch file replaces the "-c" from ssh. I'm sure someone who knows Windows batch file syntax better than I can improve on that script, but at least I can now execute remote commands on my windows portable and get some benefit from that CPU... (The only thing remaining to be done to add this system to my small cluster is to mount my cluster's NFS file system in WSL2 - which is proving problematic, but that's a question for another forum and another day.)

@robertoandrade
Copy link

Just posted an answer on #9197 (comment) but perhaps should have commented on this since it's the only open ticket related to all duplicates including the ones mentioned in #11627 so quoting it here:

Had this very issue on a Windows 11 installation and after reading through all comments here I noticed that indeed the wsl.exe copies that get installed and are available on the standard PATH aren't really the actual executables, unless they get replaced or something gets changed after reboot/repair, but debugging through the instances of wsl.exe on the system:

>where wsl.exe
C:\Windows\System32\wsl.exe
C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps\wsl.exe

>dir C:\Windows\System32\wsl.exe
 Volume in drive C has no label.
 Volume Serial Number is 6E9D-788A

 Directory of C:\Windows\System32

02/25/2024  01:48 PM           196,608 wsl.exe
               1 File(s)        196,608 bytes
               0 Dir(s)  96,262,938,624 bytes free

>C:\Windows\System32\wsl.exe --version
The file cannot be accessed by the system.

Since while running dir /s \wsl.exe found many other copies in many directories including C:\Program Files\WSL\wsl.exe I ended up testing executing the same command with that one:

>"c:\Program Files\WSL\wsl.exe" --version
WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.3155

That file seems to be much bigger than the ones on the path:

>dir /s wsl.exe
 Volume in drive C has no label.
 Volume Serial Number is 6E9D-788A

 Directory of C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_2.2.4.0_x64__8wekyb3d8bbwe

06/21/2024  07:55 PM         3,633,088 wsl.exe
               1 File(s)      3,633,088 bytes

 Directory of C:\Program Files\WSL

04/25/2024  06:19 PM         3,633,088 wsl.exe
               1 File(s)      3,633,088 bytes

 Directory of C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps

06/21/2024  07:56 PM                 0 wsl.exe
               1 File(s)              0 bytes

 Directory of C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_8wekyb3d8bbwe

06/21/2024  07:56 PM                 0 wsl.exe
               1 File(s)              0 bytes

 Directory of C:\Windows\System32

02/25/2024  01:48 PM           196,608 wsl.exe
               1 File(s)        196,608 bytes

 Directory of C:\Windows\WinSxS\amd64_microsoft-windows-lxss-wsl_31bf3856ad364e35_10.0.22621.2506_none_62c8e9f54a7fa6e6

02/25/2024  01:48 PM           196,608 wsl.exe
               1 File(s)        196,608 bytes

 Directory of C:\Windows\WinSxS\amd64_microsoft-windows-lxss-wsl_31bf3856ad364e35_10.0.22621.2506_none_62c8e9f54a7fa6e6\f

02/09/2024  08:05 PM               344 wsl.exe
               1 File(s)            344 bytes

 Directory of C:\Windows\WinSxS\amd64_microsoft-windows-lxss-wsl_31bf3856ad364e35_10.0.22621.2506_none_62c8e9f54a7fa6e6\r

02/25/2024  01:48 PM               595 wsl.exe
               1 File(s)            595 bytes

     Total Files Listed:
               8 File(s)      7,660,331 bytes
               0 Dir(s)  96,284,803,072 bytes free

So not sure if the other ones are stubs or some sort of "symbolic link" to the actual ones but they don't seem to work out of the box after installing and rebooting.

@chandragie
Copy link

On Windows 11. I disabled then reenabled (and rebooted) via Features which did nothing. Also tried the dsim recommendations to no avail. Upthread, someone mentioned the App Store. I found WSL there and Repaired it which worked. Existing containers okay.

realized that this thread is still active. this works for me 👍🏻
Thanks

@buvinghausen
Copy link

Happened again on my Surface Laptop 7 which is Snapdragon so it's a multi architecture feature ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests