SSH 进入 EMR 实例失败,出现 ssh_exchange_identification 错误

ssh into emr instance failing with ssh_exchange_identification error

我正在尝试通过 ssh 进入 emr 实例。 ip和密钥信息是正确的。关于问题可能是什么的想法?


会话跟踪:

> ssh -vv -i pemfile.pem hadoop@xx.xx.xx.xx
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 *
debug2: ssh_connect: needpriv 0
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file pemfile.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file pemfile.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
ssh_exchange_identification: Connection closed by remote host

> ls -al pemfile.pem 
-rw-r--r--  1 user  staff  1692 Aug 24 15:09 pemfile.pem

这可能是由多种问题引起的,测试步骤如下。

检查/etc/hosts.deny和/etc/hosts.allow

许多人报告说将这些正确配置为值很有帮助。但是,即使 hosts.* 文件不是一个因素,我也看到了这个问题。

root@host # grep sshd /etc/hosts.allow
sshd: ALL

缺少依赖项

这通常发生在 glibc 或 openssl 升级之后。许多发行版可以安装 glibc 或 openssl 库的更新,而不需要重新启动 sshd。

在任何发行版上,您都可以在更新后识别它,然后使用 lsof 查看 sshd 打开文件的位置。有些将指向 DEL,因为这些库在更新时被删除了。

~ # lsof -n | grep ssh | grep DEL

当 SSH 连接进入 sshd 守护程序并尝试附加 (ld) 这些 lib 文件时,失败导致此错误。

指纹/按键损坏

一些指纹或密钥中的一个或另一个已损坏(您是否手动编辑了其中一个文件?)。删除客户端 ~/.ssh/known_hosts 中的服务器端指纹,然后重试。当您重新连接时,系统会提示您再次接受主机身份。

如果您能够以其他方式访问计算机,您可能需要退出并重新创建服务器端 ~/.ssh/authorized_keys.

按照与此问题相同的思路,如果文件 /etc/ssh/key 被删除并且 sshd 未重新启动,那么也会出现此错误。检查 sshd 配置目录中的密钥文件。

服务器负载大

当服务器负载过重(例如,暴力攻击)时,也会发生这种情况。增加sshd的连接数可以运行.

root@host # grep MaxStartups /etc/ssh/sshd_config
# Old Style
MaxStartups 12
# New Style
MaxStartups 10:20:30

参考:http://edoceo.com/notabene/ssh-exchange-identification