突然,我无法ssh
使用无线接口连接到服务器,但我可以使用 eth0 接口通过电缆直接连接到路由器来实现。
我从无线接口获得:
$ ssh -vvv my_server
OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 38: Applying options for my_server
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname XX.XXX.XX.XXX is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/user/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/user/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to XX.XXX.XX.XXX [XX.XXX.XX.XXX] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: connect to address XX.XXX.XX.XXX port 22: Network is unreachable
ssh: connect to host XX.XXX.XX.XXX port 22: Network is unreachable
并且tcpdump
是:
$ sudo tcpdump -v -i any tcp port 22
tcpdump: data link type LINUX_SLL2
tcpdump: listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
19:56:14.312414 wlp0s20f3 Out IP (tos 0x10, ttl 64, id 25412, offset 0, flags [DF], proto TCP (6), length 60)
myhost.52266 > ec2-XX-XXX-XX-XXX.eu-central-1.compute.amazonaws.com.ssh: Flags [S], cksum 0x36d4 (incorrect -> 0xcc4d), seq 1642097124, win 64240, options [mss 1460,sackOK,TS val 1123249955 ecr 0,nop,wscale 7], length 0
从我的 eth 接口:
$ ssh -vvv my_server
OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 38: Applying options for my_server
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname XX.XXX.XX.XXX is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/user/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/user/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to XX.XXX.XX.XXX [XX.XXX.XX.XXX] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: Connection established.
并且tcpdump
是:
$ sudo tcpdump -v -i any tcp port 22
tcpdump: data link type LINUX_SLL2
tcpdump: listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
22:14:16.335219 enp0s31f6 Out IP (tos 0x10, ttl 64, id 48434, offset 0, flags [DF], proto TCP (6), length 60)
ws5.51632 > ec2-XX.XXX.XX.XXX.eu-central-1.compute.amazonaws.com.ssh: Flags [S], cksum 0x36d1 (incorrect -> 0xdbb4), seq 1199071061, win 64240, options [mss 1460,sackOK,TS val 151306527 ecr 0,nop,wscale 7], length 0
22:14:16.390032 enp0s31f6 In IP (tos 0x0, ttl 48, id 0, offset 0, flags [DF], proto TCP (6), length 60)
ec2-XX.XXX.XX.XXX.eu-central-1.compute.amazonaws.com.ssh > ws5.51632: Flags [S.], cksum 0xdc56 (correct), seq 1641064052, ack 1199071062, win 62643, options [mss 1440,sackOK,TS val 2605867526 ecr 151306527,nop,wscale 7], length 0
22:14:16.390126 enp0s31f6 Out IP (tos 0x10, ttl 64, id 48435, offset 0, flags [DF], proto TCP (6), length 52)
ws5.51632 > ec2-XX.XXX.XX.XXX.eu-central-1.compute.amazonaws.com.ssh: Flags [.], cksum 0x36c9 (incorrect -> 0xfd95), ack 1, win 502, options [nop,nop,TS val 151306582 ecr 2605867526], length 0
22:14:16.397623 enp0s31f6 Out IP (tos 0x10, ttl 64, id 48436, offset 0, flags [DF], proto TCP (6), length 84)
ws5.51632 > ec2-XX.XXX.XX.XXX.eu-central-1.compute.amazonaws.com.ssh: Flags [P.], cksum 0x36e9 (incorrect -> 0x92b6), seq 1:33, ack 1, win 502, options [nop,nop,TS val 151306590 ecr 2605867526], length 32: SSH: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3
我的工作接口是 enp0s31f6 (以前的 eth0):
2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
失败的是wifi市场noqueue
:
3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
我发现一个非常有趣的现象:我的地址是 IPv4 地址~/.ssh/config
,但日志显示 TCP(6)。我猜那意味着 IPv6。我尝试使用选项强制执行,-4
但结果是一样的。
我的~/.ssh/config
是:
Host $ ssh -vvv my_server
Hostname XX.XXX.XX.XXX
User ubuntu
IdentityFile ~/.ssh/my_id.pem
我ethtool -S wlp0s20f3
可以看到连接中没有丢失数据包。
这可能是什么原因?
答案1
我有debug3: set_sock_tos: set socket 3 IP_TOS 0x10
和你提到的相同的痕迹,结果发现,对于我的具体情况,我解决了它这个答案,这与我的路由器如何管理 WiFi 的 QoS 有关。只需添加,-o IPQoS=none
我终于能够连接:
axel@PTT426:~$ ssh -o IPQoS=none -i ~/.ssh/id_ed25519 -vvv [email protected]
OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/axel/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/axel/.ssh/known_hosts2'
debug2: resolving "github.com" port 22
debug3: resolve_host: lookup github.com:22
debug3: ssh_connect_direct: entering
debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
通过将其添加到我的文件顶部,~/.ssh/config
我得到了针对每个git
和ssh
操作都修复的if:
Host *
IPQoS=none
希望能帮助到你! :)