简体   繁体   English

不能 ssh 从 windows PC 到 WSL

[英]Cannot ssh to WSL from windows PC

I want to ssh to WSL on my windows PC.我想在我的 windows PC 上将 ssh 连接到 WSL。 The port forwarding rule has been set up properly with.netsh.已使用 .netsh 正确设置端口转发规则。

ADDRESS         PORT        ADDRESS         PORT      
--------------- ----------  --------------- ----------
0.0.0.0         3333        172.19.56.231   22

The address to be connected is obtained through wsl -d "Ubuntu-22.04" hostname -I要连接的地址通过wsl -d "Ubuntu-22.04" hostname -I获取

I can ssh to WSL through ssh shflte@172.19.56.231 .我可以通过ssh shflte@172.19.56.231将 ssh 转到 WSL。 But I cannot ssh to WSL through ssh shflte@192.168.100.156 -p 3333 (192.168.100.156 is my PC's address).但是我不能通过ssh shflte@192.168.100.156 -p 3333将 ssh 连接到 WSL(192.168.100.156 是我的 PC 地址)。 So I guess the problem did not come from the WSL.所以我猜问题不是出在 WSL 上。

ssh message: ssh 留言:

ssh shflte@192.168.100.156 -p 3333 -v
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\SH/.ssh/config
debug1: Connecting to 192.168.100.156 [192.168.100.156] port 3333.
debug1: connect to address 192.168.100.156 port 3333: Connection refused
ssh: connect to host 192.168.100.156 port 3333: Connection refused

Can anyone tell me why did I get Connection refused ?谁能告诉我为什么Connection refused

This is possibly related to a firewall problem.这可能与防火墙问题有关。 To verify that the firewall is allowing incoming connections on port 3333, you can do the following command in PowerShell:要验证防火墙是否允许端口 3333 上的传入连接,您可以在 PowerShell 中执行以下命令:

netsh advfirewall firewall show rule name=all dir=in | findstr "3333"

In the case where the firewall is actually the problem, you can allow incoming connections on port 3333:如果防火墙确实是问题所在,您可以允许端口 3333 上的传入连接:

netsh advfirewall firewall add rule name="SSH_WSL" dir=in action=allow protocol=TCP localport=3333

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM