Ssh

ssh_dispatch_run_fatal:消息驗證碼不正確

  • May 27, 2021

幾天以來,我在 ssh 中連接到我的伺服器時遇到了一個問題,用於代理/隧道使用。

我 - 設置

客戶

這是機器:

iMac:~ 盧卡$ sw_vers

產品名稱:Mac OS X

產品版本:10.11.6

建構版本:15G1108

iMac:~ Luca$ sudo sysctl net.inet.ip.forwarding

net.inet.ip.forwarding: 0

iMac:~ Luca$ sudo sysctl net.inet.ip.fw.enable

net.inet.ip.fw.enable: 1

在三個不同的網路上嘗試過。

瀏覽器

我正在使用 Firefox 50.0.1 瀏覽網際網路,FoxyProxy 擴展配置如下:

主機地址:127.0.0.1

埠:9999

襪子 v5

SSH 命令

我正在使用 Terminal.app 通過 ssh 連接到我的伺服器。

iMac:~ Luca$ ssh -p 53 -D 9999 luca@myIP

伺服器

luca@myServer:~$ ssh -V

OpenSSH_6.7p1 Debian-5+deb8u3,OpenSSL 1.0.1t 2016 年 5 月 3 日

luca@myServer:~$ cat /proc/sys/net/ipv4/ip_forward

1

II - 預期

連接打開後,我可以毫無問題地瀏覽任何網站(我的 IP 是我的伺服器)。

這很好,直到幾天。如果我嘗試,這仍然很好:

  • 同一台伺服器 (A),另一台電腦 (Y)
  • 同一台電腦 (X),另一台伺服器 (B)

從它的外觀來看,它不適用於我的電腦 (X) 和我的伺服器 (A)。

III - 會發生什麼

luca@myServer:~$ ssh_dispatch_run_fatal: 連接到 myIP: 消息驗證碼不正確

然後關閉連接。

此消息隨機出現。但我可以通過代理載入大數據輕鬆重現它:載入多個影片、下載大文件等……

IV - 另一種方式,類似的問題

如果我通過 sftp://(使用 FileZilla)使用相同的登錄名(luca)和相同的埠(53)連接到我的伺服器。然後我嘗試下載一個文件,每 <30 秒我收到以下錯誤:

錯誤:在數據包上收到不正確的 MAC

再一次,這只發生在我的電腦 (X) 和我的伺服器 (A) 上。如果我在同一台電腦 (X) 上嘗試另一台伺服器 (B):沒問題。如果我在另一台電腦 (Y) 上嘗試相同的伺服器 (A):沒問題。

V - 我嘗試過的(但沒有解決)

  1. 重新啟動伺服器和電腦
  2. 在伺服器和電腦上重新啟動 ssh/sshd
  3. 刪除電腦上的knowns_hosts文件
  4. 使用 ssh 命令指定 a-m-c
  5. -o GSSAPIKeyExchange=no在 ssh 命令中指定 a
  6. /etc/ssh/ssh_config取消註釋伺服器或/和電腦上的密碼和/或 MAC 行
  7. 嘗試-vvvvv使用 ssh 命令查看選項並讀取伺服器/電腦上的日誌,看起來沒有任何關係。

任何幫助,將不勝感激。

附錄

伺服器ssh -Q mac

luca@myServer:~$ ssh -Q mac hmac-sha1 hmac-sha1-96 hmac-sha2-256 hmac-sha2-512 hmac-md5 hmac-md5-96 hmac-ripemd160 hmac-ripemd160@openssh.com umac-64@ openssh.com umac-128@openssh.com hmac-sha1-etm@openssh.com hmac-sha1-96-etm@openssh.com hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh .com hmac-md5-etm@openssh.com hmac-md5-96-etm@openssh.com hmac-ripemd160-etm@openssh.com umac-64-etm@openssh.com umac-128-etm@openssh.com

電腦ssh -Q mac

iMac:~ Luca$ ssh -Q mac hmac-sha1 hmac-sha1-96 hmac-sha2-256 hmac-sha2-512 hmac-md5 hmac-md5-96 hmac-ripemd160 hmac-ripemd160@openssh.com umac-64@openssh .com umac-128@openssh.com hmac-sha1-etm@openssh.com hmac-sha1-96-etm@openssh.com hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh。 com hmac-md5-etm@openssh.com hmac-md5-96-etm@openssh.com hmac-ripemd160-etm@openssh.com umac-64-etm@openssh.com umac-128-etm@openssh.com

伺服器ssh -v -p 53 -D 9999 luca@myIP

iMac:~ Luca$ ssh -v -p 53 -D 9999 luca@myIP

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to myIP [myIP] port 53.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Luca/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5+deb8u3
debug1: match: OpenSSH_6.7p1 Debian-5+deb8u3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to myIP:53 as 'luca'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server-&gt;client chacha20-poly1305@openssh.com &lt;implicit&gt; none
debug1: kex: client-&gt;server chacha20-poly1305@openssh.com &lt;implicit&gt; none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:DUAAYL1r0QUDtRI89JozTTz+bm5wcg4cOSaFaRdbr/Y
debug1: Host '[myIP]:53' is known and matches the ECDSA host key.
debug1: Found key in /Users/Luca/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/Luca/.ssh/id_rsa
debug1: Trying private key: /Users/Luca/.ssh/id_dsa
debug1: Trying private key: /Users/Luca/.ssh/id_ecdsa
debug1: Trying private key: /Users/Luca/.ssh/id_ed25519
debug1: Next authentication method: password

luca@myIP's password:

debug1: Authentication succeeded (password).
Authenticated to myIP ([myIP]:53).
debug1: Local connections to LOCALHOST:9999 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 9999.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 9999.
debug1: channel 1: new [port listener]
debug1: channel 2: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = fr_FR.UTF-8
Debian GNU/Linux 8.6

Linux &lt;server&gt; #1 SMP Tue Mar 18 14:48:24 CET 2014 x86_64 GNU/Linux

server    : 274305
hostname  : myServer
eth0 IPv4 : myIPv4
eth0 IPv6 : myIPv6
Last login: Thu Dec  8 15:36:09 2016 from XXX.XXX.XXX.XXX

luca@myServer:~$

我有時看到的錯誤

luca@myServer:~$ 錯誤數據包長度 3045540078。

填充錯誤:需要 -1249427218 塊 8 mod 6

ssh_dispatch_run_fatal:連接到 5.39.88.21:消息驗證碼不正確

ssh -o macs=hmac-sha1 -v -p 53 -D 9999 luca@myServer發生崩潰時的伺服器

iMac:~ Luca$ ssh -o macs=hmac-sha1 -v -p 53 -D 9999 luca@myIP
// [...]
luca@myServer:~$ debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 3: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 4: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 5: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 6: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 7: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 8: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 9: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 10: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 11: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 12: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 13: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 14: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 15: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 16: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 17: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 18: new [dynamic-tcpip]
debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 19: new [dynamic-tcpip]
ssh_dispatch_run_fatal: Connection to myIP : message authentication code incorrect
iMac:~ Luca$

在客戶端更新 SSH 後

iMac:~ Luca$ ssh -V
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016

iMac:~ Luca$ ssh -p 53 -D 9999 luca@myIP
luca@myIP's password: 
luca@ns3274305:~$ ssh_dispatch_run_fatal: Connection to myIP port 53: message authentication code incorrect

iMac:~ Luca$ ssh -o macs=hmac-sha1 -p 53 -D 9999 luca@myIP
luca@myIP's password: 
luca@ns3274305:~$ ssh_dispatch_run_fatal: Connection to myIP port 53: message authentication code incorrect
iMac:~ Luca$

我已經從 Mac OS El Capitan (10.11) 更新到 Mac OS Sierra (10.12)。

問題不再發生。

我仍然不知道真正的問題是什麼。

通過在 Mac 上乙太網適配器的高級設置(在 Big Sur 下)禁用 AVB/EAV 模式,我解決了這個問題。

引用自:https://unix.stackexchange.com/questions/328912