ssh_exchange_identification: Connection closed by remote host lost connection
时间: 2023-11-21 13:54:17 浏览: 30
ssh_exchange_identification: Connection closed by remote host lost connection是由于SSH客户端和服务器之间的密钥交换失败导致的。这可能是由于网络连接问题,SSH配置错误或安全软件阻止连接等原因引起的。如果问题是偶尔出现的,那么可能是由于服务器负载过高或网络拥塞等原因导致的。建议检查SSH配置和网络连接,以确定问题的根本原因。
相关问题
ssh_exchange_identification: Connection closed by remote host
当你在尝试连接虚拟机时,有时会遇到"ssh_exchange_identification: Connection closed by remote host"的错误提示。这个错误通常表示与远程主机的连接被关闭。解决这个问题的步骤如下:
1. 首先,使用以下命令查看主机上的ssh连接情况:sudo netstat -tnpa | grep 'ESTABLISHED.*sshd'。这将显示所有已建立的ssh连接。你可能会注意到有很多未知的连接,尤其是来自四台机器的连接。这可能是导致无法新建其他ssh连接的原因。
2. 为了解决这个问题,你可以使用iptables命令封锁掉这几个IP地址。运行以下命令封锁IP地址:sudo iptables -I INPUT -s [需要封锁的IP地址] -j DROP。这将阻止这些IP地址的连接,从而解决连接问题。
3. 如果你使用了DenyHosts服务,你可以将被禁止的主机IP添加到允许列表中。使用以下命令将IP地址添加到允许列表中:echo "127.0.0.1" >> /var/lib/denyhosts/allowed-hosts。然后,重启DenyHosts服务以使更改生效。
4. 如果以上步骤仍然无法解决问题,你可以尝试编辑文件/var/log/secure和/etc/hosts.deny,删除其中包含被禁止主机IP的行。使用以下命令进行编辑:sed -i '/127.0.0.1/d' /var/log/secure 和 sed -i '/127.0.0.1/d' /etc/hosts.deny。
通过执行这些步骤,你应该能够解决ssh_exchange_identification: Connection closed by remote host的错误,并且能够成功连接到虚拟机。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ssh_exchange_identification: Connection closed by remote host](https://blog.csdn.net/qq_42711381/article/details/129721340)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [基础篇(一):ssh登录主机报错:ssh_exchange_identification:Connection closed by remote host](https://blog.csdn.net/weixin_44533362/article/details/86493616)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
如何解决ssh_exchange_identification: Connection closed by remote host
根据提供的引用内容,解决"ssh_exchange_identification: Connection closed by remote host"错误的方法是修改SSH服务器的配置文件。具体步骤如下:
1. 使用管理员权限打开SSH服务器的配置文件`/etc/ssh/sshd_config`。
2. 找到`PasswordAuthentication`这一行,并将其值改为`yes`。
3. 保存并关闭文件。
4. 重启SSH服务器,以使更改生效。
下面是一个示例的命令行操作:
```shell
sudo nano /etc/ssh/sshd_config
```
找到以下行并修改:
```
PasswordAuthentication yes
```
保存并关闭文件后,重启SSH服务器:
```shell
sudo service ssh restart
```
这样,你应该能够成功解决"ssh_exchange_identification: Connection closed by remote host"错误。