当我尝试ssh时如何解决"找不到匹配的mac错误"



以下是我得到的错误:未找到匹配的mac:客户端hma-md5、hmac-sha1、hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha-196,hmac-md5-96服务器hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com

在了解基本原理和根本原因之前,我已经为这个问题挣扎了很长一段时间。分享经验,让它帮助别人。

我试图通过ssh连接到目标服务器,但出现了如下所示的错误

$ ssh -A <someTargetServerNameOrIP>
Unable to negotiate with XX.XX.XX.XX port 1234: no matching MAC found.   
Their offer:   
hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,
umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com

此错误的根本原因是源计算机上支持的MAC不包含来自目标服务器的MAC。

在你的机器上看到这个运行命令行

$ ssh -Q mac   # output would be something like
hmac-sha1
hmac-sha1-96
hmac-sha2-256
hmac-sha2-512
hmac-md5
hmac-md5-96
umac-64@openssh.com
umac-128@openssh.com

因此,现在为了连接到目标服务器,让他们选择你的服务器不支持的mac,你必须明确提供目标服务器支持的mac之一。例如,我们从错误消息中提取hmac-sha2-512并尝试连接,它将被连接

$ ssh -m hmac-sha2-512 -A <someTargetServerNameOrIP>

问题的另一个变体是密码不匹配,看起来低于

$ ssh -A <someTargetServerNameOrIP>       
Unable to negotiate with XX.XX.XX.XX port 1234: no matching cipher found.   
Their offer: aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc

根本原因是密码不匹配

通过检查您支持的密码

$ ssh -Q cipher   # output would be something like
3des-cbc
aes256-cbc
rijndael-cbc@lysator.liu.se
aes128-ctr
aes192-ctr
aes256-ctr
aes128-gcm@openssh.com
aes256-gcm@openssh.com

因此,现在为了连接到目标服务器并选择您的服务器不支持的密码,您必须明确提供目标服务器支持的密码之一。例如,我们从错误消息中获取aes128 cbc并尝试连接,它将被连接

$ ssh -c aes128-cbc -A <someTargetServerNameOrIP>

可以找到更多详细信息https://diego.assencio.com/?index=688f3a536f63c43566c94f0818d9ecf3

希望这能帮助到别人。

您收到此错误是因为客户端和服务器无法就消息身份验证代码的哈希算法达成一致。

更多信息请点击此处:https://blog.tinned-software.net/debug-ssh-connection-issue-in-key-exchange/

在centOS/RHEL 7服务器中,试图通过TMA脉冲安全工具访问服务器,并在/var/log/secure 上获得以下错误

[root@rhellinuxserver~]#cat/var/log/secure|grep-iE"不匹配"8月24日07:02:07 rhellinuxserver sshd[29958]:无法与172.21.112.111端口16899进行协商:找不到匹配的MAC。他们的报价:hmac-sha1,hmac-sha-196,hmac-md5,hmac-d5-96,hmac-ripemd160,hmac-ripemd160@openssh.com[预先鉴定]8月24日07:15:24 rhellinuxserver sshd[37002]:无法与172.21.112.111端口33541进行协商:找不到匹配的MAC。他们的报价:hmac-sha1,hmac-sha-196,hmac-md5,hmac-d5-96,hmac-ripemd160,hmac-ripemd160@openssh.com[previauth]

要修复此问题,请编辑下面提到的sshd_config文件

#cat-n/etc/ssh/sshd_config|grep-i MAcs

查找行

MAChmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com

用替换

MACs hmac-sha1、hmac-sha-196、hmac-md5,hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160

这将添加以下额外的MAC算法。

hmac-sha1,hmac-sha-196,hmac-md5,hmac-ripemd160

立即重新启动SSHD服务

systemctl-restart sshd

现在可以访问服务器,并在/var/log/secure日志文件中找到成功结果。

cat/var/log/secure|grep-i已接受8月24日07:18:24 rhellinuxserver sshd[548]:从172.21.112.111端口53776 ssh2

接受用户名密码重要提示:

不要使用这两个弱密码aes256 cbc&aes128 cbc

这可能使攻击者能够从密文中恢复明文消息。

禁用CBC模式密码加密并启用CTR或GCM密码模式加密。

以下是禁用SSH弱密码的步骤aes256 cbc&aes128 cbc

步骤1:删除AES-128-CBC&此文件上的AES-256-CBC

/etc/crypto-policies/state/CURRENT.pol 

步骤2:删除aes256 cbc&aes128 cbc。

/etc/crypto-policies/back-ends/opensshserver.config

步骤3:重新启动/重新加载sshd服务

$ sudo systemctl restart sshd
$ sudo systemctl status sshd

第4步:现在您可以在没有弱密码aes256 cbc&aes128 cbc

$ sudo ssh -vvv user-name@IP-Address

有关更多信息,请参阅CVE-2008-5161

最新的腻子客户端解决了这个问题。

相关内容

最新更新