Linux : 如何解决 SSH 上的算法协商失败问题

举报
Tiamo_T 发表于 2021/09/24 16:13:12 2021/09/24
【摘要】 从本地主机到使用不同 ssh 版本的远程主机执行 ssh 时,您可能会收到“算法协商失败”消息。在这篇文章中,我将解释如何从 ssh 客户端解决这个问题。 1. Unable to ssh to remote-host:在这个例子中,当尝试从本地主机到远程主机执行 ssh 时,我们得到“算法协商失败”错误消息,如下所示。请注意本地主机正在运行 ssh2 客户端。[local-host]$ s...

从本地主机到使用不同 ssh 版本的远程主机执行 ssh 时,您可能会收到“算法协商失败”消息。在这篇文章中,我将解释如何从 ssh 客户端解决这个问题。

 
1. Unable to ssh to remote-host:在这个例子中,当尝试从本地主机到远程主机执行 ssh 时,我们得到“算法协商失败”错误消息,如下所示。请注意本地主机正在运行 ssh2 客户端。

[local-host]$ ssh -l tiamo remote-host
warning: Authentication failed.
Disconnected; key exchange or algorithm negotiation failed (Algorithm negotiation failed.).

[local-host]$ ssh -V
ssh: SSH Secure Shell 3.2.9.1 (non-commercial version) on i686-pc-linux-gnu
[local-host]$ ls -l /usr/local/bin/ssh
lrwxrwxrwx  1 root root 4 Mar 10 22:04 /usr/local/bin/ssh -> ssh2

 
2. 从 SSH 获取有关错误消息的更多调试信息。将 -v 参数传递给 ssh 客户端以查看其他调试信息,这将有助于进一步解决此问题,如下所示。

[local-host]$ ssh -v -l tiamo remote-host
debug: SshConfig/sshconfig.c:2838/ssh2_parse_config_ext: Metaconfig parsing stopped at line 3.
debug: SshConfig/sshconfig.c:637/ssh_config_set_param_verbose: Setting variable 'VerboseMode' to 'FALSE'.
debug: SshConfig/sshconfig.c:3130/ssh_config_read_file_ext: Read 17 params from config file.
debug: Ssh2/ssh2.c:1707/main: User config file not found, using defaults. (Looked for '/home/tiamo/.ssh2/ssh2_config')
debug: Connecting to 192.168.101.107, port 22... (SOCKS not used)
debug: Ssh2Transport/trcommon.c:3676/ssh_tr_create: My version: SSH-1.99-3.2.9.1 SSH Secure Shell (non-commercial)
debug: client supports 2 auth methods: 'publickey,password'
debug: Ssh2Common/sshcommon.c:537/ssh_common_wrap: local ip = 192.168.1.2, local port = 59514
debug: Ssh2Common/sshcommon.c:539/ssh_common_wrap: remote ip = 192.168.1.3, remote port = 22
debug: SshConnection/sshconn.c:1945/ssh_conn_wrap: Wrapping...
debug: SshReadLine/sshreadline.c:2427/ssh_readline_eloop_initialize: Initializing ReadLine...
debug: Remote version: SSH-2.0-OpenSSH_5.0
debug: OpenSSH: Major: 5 Minor: 0 Revision: 0
debug: Ssh2Transport/trcommon.c:973/ssh_tr_input_version: All versions of OpenSSH handle kex guesses incorrectly.
debug: Ssh2Transport/trcommon.c:1116/ssh_tr_negotiate_one_alg: Algorithm negotiation failed for c_to_s_compr: client list: zlib vs. server list : none,zlib@openssh.com
debug: Ssh2Transport/trcommon.c:1116/ssh_tr_negotiate_one_alg: Algorithm negotiation failed for s_to_c_compr: client list: zlib vs. server list : none,zlib@openssh.com
debug: Ssh2Transport/trcommon.c:1367/ssh_tr_negotiate: lang s to c: `', lang c to s: `'
debug: Ssh2Common/sshcommon.c:169/ssh_common_disconnect: DISCONNECT received: Algorithm negotiation failed.
debug: SshReadLine/sshreadline.c:2485/ssh_readline_eloop_uninitialize: Uninitializing ReadLine...
warning: Authentication failed.
Disconnected; key exchange or algorithm negotiation failed (Algorithm negotiation failed.).
debug: Ssh2Common/sshcommon.c:662/ssh_common_destroy: Destroying SshCommon object.
debug: SshConnection/sshconn.c:1997/ssh_conn_destroy: Destroying SshConn object.

根据调试消息中显示的调试信息消息:“ Algorithm notice failed for s_to_c_compr: client list: zlib vs. server list : none,zlib@openssh.com ”,很明显客户端(本地主机)是使用 zlib 压缩并且服务器(远程主机)未使用 zlib。

 
3.通过不压缩连接到远程主机SSH解决问题。将-o“压缩号”传递给ssh客户端即可解决问题,如下图。

[local-host]$ ssh -o "Compression no" -l tiamo remote-host
tiamo@remote-host's password:
Last login: Wed Jun 25 17:06:31 2020 from 192.168.1.2

[remote-host]$ ssh -V
OpenSSH_5.0p1, OpenSSL 0.9.8g 19 Oct 2019

现在您在将-o “Compression no”参数传递给 ssh 客户端后连接没有任何问题,您可以注意到远程主机正在使用 openSSH,这与在本地主机上运行的 ssh 不同,后者是是算法协商失败问题的原因。

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。