因此,我尝试配置我的 Ubuntu 22 笔记本电脑以连接运行 WSL 的 Windows 11 计算机。昨天效果很好,我可以想象我想要的一切。但现在我无法连接。这就是ssh -vvv username@ip_address -p 2222
客户端给我的:
OpenSSH_8.9p1 Ubuntu-3ubuntu0.6, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 19: Including file /etc/ssh/ssh_config.d/dummy.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/dummy.conf
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname [[ip_address]] is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/marlen/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/marlen/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to [[ip_address]] [[[ip_address]]] port 2222.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: connect to address [[ip_address]] port 2222: Connection timed out
ssh: connect to host [[ip_address]] port 2222: Connection timed out
我在 Windows 系统中配置了重定向,如下所示:
netsh interface portproxy add v4tov4 listenaddress=[[ip_address]] listenport=2222 connectaddress=[[internal_ip_address]] connectport=22
因此我尝试进入端口 22。另外,我为防火墙添加了一条规则,如下所示:
netsh advfirewall firewall add rule name=WSL2 dir=in action=allow protocol=TCP localport=2222
由于我一直在尝试重新创建昨天的流程,因此存在多个 WSL2 规则。我想知道这是否是一个原因。
这是我的 WSL2 的额外信息:
sudo service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; ven>
Active: active (running) since Thu 2024-03-28 11:57:10 -05; 2>
======
sudo netstat -paunt | egrep sshd\|:22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 51694/sshd: /usr/sb
tcp6 0 0 :::22 :::* LISTEN 51694/sshd: /usr/sb
看起来关于 ip 一切都很好:
在 Windows 上:
Wireless LAN Wi-Fi 2:
IPv4. . . . . . . . . . . . . . : 192.168.0.149
关于 WSL
$ ip addr | grep eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 172.21.135.113/20 brd 172.21.143.255 scope global eth0
这就是我所掌握的全部信息。感谢您为我提供的任何帮助。