WSL SSH 允许局域网访问

#Allow LAN access

Can listen to localhost, windows and wsl seem to be sharing localhost.

For example, if I want to access wsl ssh on the LAN, I use the netsh command to forward the request to the localhost:

netsh interface portproxy add v4tov6 listenaddress=0.0.0.0 listenport=22 connectaddress=localhost connectport=22 protocol=TCP

Use the following command to see the result:

netsh interface portproxy show

Note: You need to confirm whether your localhost is ipv6 or ipv4, use ping localhost to check

Change network to private network or public network

Windows 重命名网络适配器以及切换网络类型 > 切换网络类型

#Automatic start of WSL at power-on(User login)

Press Win + R and enter taskschd.msc to access Task Scheduler, Right side click Create Task.

In General tab enter Name field, Description field and click Hidden checkbox, Then, Switch to the Actions tab,

Click New button, Enter pwsh in Program/script, then -WindowStyle hidden -Command "bash ~" in Add arguments (optional) and finally click the Ok button.

339 Words

最后更新于