In this post we show the steps to setup SSH into WSL2.
Reference:
https://www.hanselman.com/blog/how-to-ssh-into-wsl2-on-windows-10-from-an-external-machine
On WSL2
1
2
3
4
5
6
7
8
9
10
11
|
sudo apt install openssh-server
sudo vim /etc/ssh/sshd_config
# uncomment these two lines
Port 22
ListenAddress 0.0.0.0
sudo service ssh start
ip a
# assuming the ip is 192.168.121.141 and username is pi
|
On Windows
Open a CMD as Admintrator
1
2
3
4
5
6
7
8
9
10
|
# port-forward
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectaddress=192.168.121.141 connectport=22
# open firewall
netsh advfirewall firewall add rule name=”Open Port 22 for WSL2” dir=in action=allow protocol=TCP localport=22
# ipconfig
# assuming Windows' IP is 10.0.0.25
10.0.0.25
|
On 3rd machine