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 · 40 comments
Open
1 of 2 tasks

Cannot start wsl in ssh session. #7900

Domain opened this issue Jan 7, 2022 · 40 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!

@hanssonduck
Copy link

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

@hanssonduck
Copy link

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

@luckymomohd
Copy link

I found a solution for me:

@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 2415777318c@gmail.com.

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

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