Installation#
Actually, it's very simple to open directly, just install openssh-client
and openssh-server
apt install openssh-client openssh-server
Enable#
After installation, change the port to avoid being attacked every day
Since systemctl
is basically disabled in WSL, it cannot be started directly using systemctl
So, use the more primitive service
service ssh start
Auto-Start#
Here, a more abstract method is needed to start the wsl's sshd along with Windows
Enter shell:startup
in the Windows run
Then open a directory, create a .vbs
file with any name inside, and then...
This is the key point
Then go in and edit and enter this string
Set ws = WScript.CreateObject("WScript.Shell")
ws.run "wsl -d <your system name> -u root /usr/sbin/service ssh --full-restart", vbhide
I use Debian as an example here
Then save, that's it
Completion#
Then you can try to connect, you can test with Windows cmd
Okay, everything is normal
This tutorial ends here. If it helps you, feel free to share it with others
And please give it a thumbs up, if you are able to, please support, your like is my motivation for updates, thank you meow
This article is synchronized and updated to xLog by Mix Space
The original link is https://blog.nekorua.com/posts/technology/122.html