来自中国的 SSH 连接尝试显示不同的密钥;中国是否对 SSH 流量进行 MITM 攻击?

信息安全 SSH 中间人
2021-08-15 20:18:01

我有一台位于美国的服务器,并从世界各地通过 SSH 连接到它。当我从以前从未使用过的计算机上 SSH 时,我会看到如下内容:

The authenticity of host 'my.usa.server.com (11.22.33.44)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:b8:1d:61.
Are you sure you want to continue connecting (yes/no)? 

在世界上大多数地方,RSA 指纹都是相同的,这是有道理的,因为我总是连接到同一台服务器:

[来自瑞典的服务器]

me@sweden:~$ ssh myaccount@my.usa.server.com
The authenticity of host 'my.usa.server.com (11.22.33.44)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:b8:1d:61.
Are you sure you want to continue connecting (yes/no)? 
me@sweden:~$

[来自荷兰的服务器]

me@nl:~$ ssh myaccount@my.usa.server.com
The authenticity of host 'my.usa.server.com (11.22.33.44)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:b8:1d:61.
Are you sure you want to continue connecting (yes/no)? 
me@nl:~$

[来自美国的服务器]

me@otherusaserver:~$ ssh myaccount@my.usa.server.com
The authenticity of host 'my.usa.server.com (11.22.33.44)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:b8:1d:61.
Are you sure you want to continue connecting (yes/no)? 
me@otherusaserver:~$

但是,当我尝试从中国的服务器连接时,密钥指纹不同:

me@chinaserver:~$ ssh myaccount@my.usa.server.com
The authenticity of host 'my.usa.server.com (11.22.33.44)' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:d8:0f:01.
Are you sure you want to continue connecting (yes/no)? 
me@chinaserver:~$

请注意,密钥和密码是不同的。需要注意的是,我拥有中国物理服务器和它所在的房间,所以我可以确定服务器硬件是安全的。

这是否意味着上游的某个人,例如中国政府或 ISP(中国电信)正在进行某种 MITM 攻击?

2个回答

查看服务器的回答:

RSA 密钥指纹为 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:b8:1d:61。

和:

ECDSA 密钥指纹为 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:d8:0f:01。

这不是相同的密钥类型,因此也不是相同的密钥:第一种情况是 RSA,第二种情况是 ECDSA。

SSH 服务器可以使用多种加密算法,甚至可以使用多种密钥。将使用什么算法取决于客户端和服务器支持什么,以及它们的优先顺序很有可能您的 SSH 服务器同时具有 RSA 和 ECDSA 密钥对,而中国客户端恰好被配置为将 ECDSA 在其首选项列表中比其他客户端更高。

如果不确定,请尝试使用-vvv命令行选项运行 SSH 客户端,以查看客户端和服务器实际发送的内容。

密码选择是问题,所以我对我的中国偏执感到有点傻。

强制 RSA

ssh -o HostKeyAlgorithms=ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-rsa,ssh-dss user@host

导致相同的 RSA 指纹。