【问题标题】:How to resolve 'no matching mac found error' when I try to ssh当我尝试 ssh 时如何解决“找不到匹配的 mac 错误”
【发布时间】:2019-01-01 05:53:57
【问题描述】:

以下是我得到的错误: 未找到匹配的 mac:客户端 hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,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

【问题讨论】:

    标签: openssh hmacsha1


    【解决方案1】:

    在了解基础知识和根本原因之前,我已经为这个问题苦苦挣扎了很长时间。分享经验,以帮助他人。

    我试图通过 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

    希望这对某人有所帮助。

    【讨论】:

    • 这对我有用。
    【解决方案2】:

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

    更多信息在这里: https://blog.tinned-software.net/debug-ssh-connection-issue-in-key-exchange/

    【讨论】:

    【解决方案3】:

    在 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-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com [preauth] 8 月 24 日 07:15:24 rhellinuxserver sshd[30702]:无法与 172.21.112.111 端口 33541 协商:找不到匹配的 MAC。他们的报价:hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com [preauth]

    要解决此问题,请编辑 sshd_config 文件,如下所述

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

    找线

    MACs 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 

    替换为

    MACs hmac-sha1,hmac-sha1-96,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

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

    hmac-sha1,hmac-sha1-96,hmac-md5,hmac-ripemd160 

    立即重启 SSHD 服务

     systemctl restart sshd 

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

    猫 /var/log/secure| grep -i 接受 8 月 24 日 07:18:24 rhellinuxserver sshd[548]:接受来自 172.21.112.111 端口 53776 ssh2 的用户名密码

    【讨论】:

      【解决方案4】:

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

      【讨论】:

      • 哪个版本的发行说明中提到了这个问题?
      猜你喜欢
      • 1970-01-01
      • 2020-04-23
      • 1970-01-01
      • 1970-01-01
      • 2021-03-10
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      • 2018-07-27
      相关资源
      最近更新 更多