【问题标题】:Cannot ssh to WSL from windows PC无法从 Windows PC ssh 到 WSL
【发布时间】:2023-01-21 07:44:37
【问题描述】:

我想在我的 Windows PC 上通过 SSH 连接到 WSL。 已使用 netsh 正确设置端口转发规则。

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

连接地址通过wsl -d "Ubuntu-22.04" hostname -I获取

我可以通过ssh shflte@172.19.56.231 SSH 到 WSL。但我无法通过ssh shflte@192.168.100.156 -p 3333(192.168.100.156 是我的 PC 地址)SSH 到 WSL。所以我猜问题不是出在 WSL 上。

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

谁能告诉我为什么我得到Connection refused

【问题讨论】:

    标签: ssh windows-subsystem-for-linux


    【解决方案1】:

    这可能与防火墙问题有关。要验证防火墙是否允许端口 3333 上的传入连接,您可以在 PowerShell 中执行以下命令:

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

    如果防火墙确实是问题所在,您可以允许端口 3333 上的传入连接:

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

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 2023-04-08
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 2020-09-20
      • 2021-07-23
      • 1970-01-01
      • 2017-11-29
      相关资源
      最近更新 更多