-
Notifications
You must be signed in to change notification settings - Fork 817
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
Store WSL isn't accessible from Session 0 #9231
Comments
I think this issue is already tracked internally.
https://learn.microsoft.com/en-us/windows/wsl/store-release-notes#known-issues |
Known issue, we're working on a solution. |
This is a deal breaker for some. Would be nice to get notice when it is solved. Thanks! |
Please fix this - I cannot remotely login to WSL using the builtin OpenSSH server, my scheduled tasks also stopped working. |
I had to uninstall store version of WSL to be able to run ssh server at system startup again |
If policies make it difficult to enable Windows openssh to run WSL, an alternative/workaround might be to run a second openssh server (using a different port) within WSL. At the moment this seems not to be possible. But maybe that possibility can be enabled? |
I am surprised by this. By default, I can access wsl from the native OpenSSH server by setting My problem is actually this: every time I initiate a SSH connection, I get a new WSL shell. I am unable to return back to the same session in case of disconnection events; all my background processes are gone. Each connection is therefore a new WSL instance. Should I open another ticket for this ? |
I've tried it back and forth on different installs several times, and it never worked. It's a few months ago - should it be fixed and noone here knows? Many have the issue, and it's even acknnowledged by MS... Weird!
I don't think so: interrupted ssh sessions are like logoffs, like closing a terminal emulator (historically speaking closing a terminal emulator is like logging off ;-) ) - you wouldn't expect to get your jobs back there, right... You want to look into tmux or something alike. They keep processes running wile you're off, and you can attach back to them from another shell... |
This looks weird indeed. Let me know if any of you would like more details. I just installed the "Ubuntu" app in the store using a local account.
It's exactly that! I don't find my tmux sessions when I log back in. In fact, I don't find the tmux process at all! |
I have no experience with tmux in WSL, so I can't comment from experience. But I'd think about whether your WSL - instance keeps running all the time, or wheter it has had a "reboot" in your time off - even tmux doesn't survive that ;-) Though maybe it can be made to autostart and continue processes? Dunno. I know that WSL's wakeup behavior from suspend is broken (it was in my version) - maybe another reason why tmux might vanish? Or maybe you need to start your tmux processes in a local shell and let that run? Maybe you can then attach to running tmux from ssh and not shut WSL down by logging off? And just to let others know: I did install the MS Store update again, and was immediately cut out of ssh-ing in. Fortunately it is enough to uninstall via the App-Icon that appears after the update, and the previous state returns... (i.e. no total reinstall of WSL required) And yes, if I started tmux in a local shell and kept it running, I can ssh in and out multiple times and see that tmux live on happily... Final remark for others like me who didn't realize (what for again others is likely self-evident): if it's just about ssh-ing into a running WSL from the outside (i.e. not about actually "booting" wsl): that is possible with the store version of wsl too. You access the host into a shell that doesn't depend on wsl, and from there you ssh into the running wsl: |
As @bagong mentioned it is possible to install and run a second OpenSSH server (using a different port) in your WSL instance as a workaround. This can then be combined with using the Host openssh_win32
Hostname your_computer.local
User windows_username
Host openssh_wsl
ProxyJump openssh_win32
User wsl_username
HostName localhost
Port 2222 The above example assumes that the second OpenSSH server in wsl is running on port 2222. Using this configuration it is then possible to connect to the wsl instance via the hostname ssh openssh_wsl |
While it is possible to get inside the WSL instance based on the proxy jump idea from @joes, this issue still needs to be fixed for use cases such as attempts to install a new WSL distribution on a remote Windows system over SSH. In other words anything involving the WSL executable besides getting into an instance. |
My use case is accessing WSL remotely after a cold boot. I can turn on the PC remotely via WOL and SSH into a win32 OpenSSH server, but cannot start WSL from said SSH connection (session 0). Nor is it possible to start WSL automatically on boot before a user logs in to Windows (also session 0?). For example, you cannot use Task Scheduler's "Run whether user is logged on or not" option to start My workaround has been to use RDP just to login remotely and start WSL (which is started automatically on user login by Task Scheduler). Then I can SSH directly into WSL. Does anyone know of a solution for either remotely initiating a Windows user login or remotely obtaining session 1 without the GUI overhead of the RDP/Remote Desktop app? Ideally command-line only. |
@yo1dog In an entirely different context, I know of a solution (batch file) that runs from the command line with GUI overhead, but:
This batch file uses openssl, sed to obtain, mangle and register the cert hash for a given server to avoid that cert warning. On the server, I place a different batch file in the Startup folder (your idea uses Task Scheduler). This could use the timeout command to sleep for a bit, and then logoff from the server (to gracefully terminate the RDP client) after your WSL instance has started.
To avoid OOB prompts, this needs to run even before the logon:
For the script to be run at logon, I believe you already have one.
|
@benhillis Has the team made any progress on this issue? And if not is there any quick fix to make this work? |
Also curious here - this is a bit painful, can't execute a WSL (bash) script from a service (Session ID 0). Thanks! |
For those who wan't to use WSL on a jenkins windows agent, here is my workaround. Instead of connecting via a task scheduler to the jenkins controller, after the startup of the machine, I have a jenkins job running on a linux agent, which initiates a remote desktop connection to the windows agent. In the windows task scheduler I have a task, which is started whenever a remote connection is made. This is then able to start the jenkins agent under a normal session, where wsl does in fact work. The pipeline looks something like this:
|
From my side, seems like upgrading to wsl 2.0.6 (through My setup :
(Will try other tests, but it's encouraging !) |
OK, this is really screwy. I previously ran Thanks! |
@arrmo Are you running in an elevated terminal? There is more than one |
Yep! Very odd ... but I had to |
See microsoft/WSL#9231 (comment) for details
See microsoft/WSL#9231 (comment) for details
Is there any progress on this issue? I still can't use wsl with ssh |
Just to precise my answer : I found that this seems to work on all W11 workstation but only on some W10 ones. So the issue seems not resolve for every configurations 😒 |
I run WSL 版本: 2.0.9.0
内核版本: 5.15.133.1-1
WSLg 版本: 1.0.59
MSRDC 版本: 1.2.4677
Direct3D 版本: 1.611.1-81528511
DXCore 版本: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows 版本: 10.0.22621.2715 but this problem still exists. |
This is my setup: I tried:
What actually WORK for me:
|
@litian1992 upgrading to 2.0.11 and executing still, there's use-case that is not working here. using an ssh client from linux to remotely invoke wsl as |
@rgl New install after upgrade to 2.0.11 works fine with microsoft ssh server - 2.0.9 does not work. Connecting from Linux with |
@montvid ah, without |
Here is a summary of a method I've been experimenting with to access WSL remotely via SSH, particularly effective post-reboot. Hopefully, this might be helpful for others:
|
Using wsl to access the shell makes your terminal throughput 100x slower because of conpty. |
I oppose your point. However, my wsl installation (arch linux) doesn't seem to have EDIT: |
I am looking at a simple bash function that would run this above mentioned command, and then go into some forever sleep state for that shell that wsl boots up, so wsl isnt killed and restarted continously. |
@bayeslearner anyways, shouldn't this work? What user are u trying to run that service under? |
Guys, I think I have found the final solution, thanks to @rgl for letting me know the absolute path of proper wsl file, and @bayeslearner about this NSSM cli :)
now you can see your task manager, wsl will be running 24/7 regardless whether there's any open terminal or not. It also starts this service on boot 👍 I now just need to find why wsl uses so much cpu and disk even when idle... |
@renhiyama you can |
Just to emphasize that it is IMPORTANT to configure nssm service on the logon tab with the windows user account that has access to the WSL distribution (and not system local). Another thing to add is that if you ARE going to directly connect to WSL ssh on port 22 (and optionally run windows ssh on another port), I noticed that WSL ssh disconnects very randomly. I suspect this is a bug. So you need to put
into your wsl distro's /etc/ssh/sshd_config. Changing client side config didn't help. |
@kundeng Did you remove local Administrators group rights from the user that you defined in NSSM to start WSL ? |
No, but I noticed that running as system (instead of an actual user who configured that WSL distro) will not prevent WSL from exiting once all the terminal windows are closed. Maybe there is a reason for that. |
@kundeng I had to remove the local Administrators group membership from the user that starts the WSL 2 VM/instance on boot. |
I attempted the Is there no way I can keep WSL booting automatically at server reboot, without needing me to log in, as we mainly access the server via RDP. Once I sign out, it closes the WSL app. Right now we are force-killing RDP just so we can "keep it running". But is not reliable. Any tips will be appreciated. |
See the comment earlier by @aki-k , he had to REMOVE administrator group rights from that user who is configured to start WSL in order for this method to work, and if this is true, then your current method would fail. I didn't test it, as I run my system as a user (myself) with admin rights on Windows 11 and it seems work just fine. You can try both and see which way works for you. I attached some screenshots |
Version
Multiple versions are affected
WSL Version
Kernel Version
No response
Distro Version
No response
Other Software
No response
Repro Steps
Store WSL currently isn't accessible from session 0 contexts.
This means that it's not possible to interact with WSL from remote sessions such as ssh or psremote.
If wsl.exe is called from session 0, it will exit and display:
on stdout.
The text was updated successfully, but these errors were encountered: