Skip to content

Cannot start wsl in ssh session. #7900

Closed

Description

@Domain

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

Activity

  1. benhillis commented on Jan 11, 2022

    @benhillis
    Member

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

  2. benhillis commented on Jan 11, 2022

    @benhillis
    Member
  3. Domain commented on Jan 13, 2022

    @Domain
    Author

    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.

  4. ppigazzini commented on Jan 13, 2022

    @ppigazzini

    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).

  5. Domain commented on Jan 14, 2022

    @Domain
    Author

    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!

  6. kansson commented on Apr 8, 2022

    @kansson

    Will this ever be fixed?

  7. barak14 commented on Aug 1, 2022

    @barak14

    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?

  8. zzjin commented on Aug 29, 2022

    @zzjin

    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 ?

  9. Domain commented on Sep 22, 2022

    @Domain
    Author

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

  10. mg-christian-esser commented on Sep 29, 2022

    @mg-christian-esser

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

  11. gurnec commented on Sep 29, 2022

    @gurnec

    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
    
  12. ddddavid-he commented on Oct 3, 2022

    @ddddavid-he

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

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

  13. kansson commented on Nov 8, 2022

    @kansson

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

  14. 15 remaining items

  15. kendofriendo commented on Jul 13, 2023

    @kendofriendo

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

  16. NotTheDr01ds commented on Sep 20, 2023

    @NotTheDr01ds

    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.

  17. xiaoc57 commented on Nov 4, 2023

    @xiaoc57

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

    very nice job

  18. buvinghausen commented on Nov 21, 2023

    @buvinghausen

    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.

  19. xiaoc57 commented on Dec 10, 2023

    @xiaoc57

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

    非常好的工作

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

    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].

  20. entee28 commented on Feb 13, 2024

    @entee28

    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.

  21. tgross35 commented on Feb 29, 2024

    @tgross35

    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.

  22. tgross35 commented on Mar 1, 2024

    @tgross35

    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)

  23. shihabsararrafid commented on Mar 6, 2024

    @shihabsararrafid

    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.

  24. gtoal commented on Apr 26, 2024

    @gtoal

    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.)

  25. robertoandrade commented on Jun 27, 2024

    @robertoandrade

    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.

  26. chandragie commented on Aug 5, 2024

    @chandragie

    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

  27. buvinghausen commented on Aug 21, 2024

    @buvinghausen

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

  28. craigloewen-msft commented on Feb 18, 2025

    @craigloewen-msft
    Member

    This should be fixed. Please install and use the latest version of WSL which will fix this issue, using wsl --update. If you're still seeing this issue after that please create a new issue for us to triage, I'll close this issue out for our bookkeeping. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions