Store SSH in Windows 10 Bash

I had a problem storing SSH in the Windows subsystem for Linux. It seems that if the shell is not open and bash is running, all processes in the subsystem will be killed. Is there any way to stop this?

I tried to create a service using nssm but could not get it to work. Now I'm trying to run the shell, and then just send it to the background, but I do not quite understand how to do this.

+4
source share
2 answers

You must save at least one bash console so that background tasks can continue to work: as soon as you close your last open bash console, WSL disables all running processes.

And yes, we are working to improve this scenario in the future;)

Update 2018-02-06

In the latest collections of Windows 10 Insider, we added the ability to save daemons and services running in the background , even if you close all of your Linux Consoles!

One of the remaining limitations in this scenario is that you need to manually start your services (for example, $ sudo service ssh startin Ubuntu), although we are exploring how we can let you configure which daemons / services to start automatically when you go to your machine. Updates.

+6
source

WSL-, C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\wsl.vbs

set ws=wscript.createobject("wscript.shell")
ws.run "C:\Windows\System32\bash.exe -c 'sudo /etc/rc.local'",0

/etc/rc.local , , "", :

/usr/sbin/sshd
/usr/sbin/cron
#block on this line to keep WSL running
sleep 365d

/etc/sudoers.d "rc-local", sudo:

username * = (root) NOPASSWD: /etc/rc.local
username * = (root) NOPASSWD: /usr/sbin/cron
username * = (root) NOPASSWD: /usr/sbin/sshd

1607, 1704 wsl ssh.

cron 'sudo crontab -e -u username' cron @reboot .

0

Source: https://habr.com/ru/post/1669291/


All Articles