Windows显示ssh_exchange_identification: Connection closed by remote host
时间: 2023-12-13 07:33:05 浏览: 67
Windows显示ssh_exchange_identification: Connection closed by remote host可能是由于以下原因导致的:
1.网络连接问题,例如防火墙或路由器配置问题。
2.远程主机拒绝连接,例如ssh服务未启动或配置错误。
3.客户端配置错误,例如ssh客户端版本不兼容或配置错误。
解决此问题的步骤如下:
1.检查网络连接,确保防火墙或路由器未阻止ssh连接。
2.检查远程主机的ssh服务是否已启动,并确保ssh服务的配置正确。
3.检查ssh客户端的配置是否正确,例如ssh客户端版本是否与远程主机兼容,以及ssh客户端的配置是否正确。
以下是一些可能有用的命令:
1.使用telnet测试ssh端口是否开放:
```shell
telnet <remote_host> 22
```
如果连接成功,则ssh端口已开放。
2.使用ssh -v命令查看ssh客户端的详细输出,以便确定连接问题的原因:
```shell
ssh -v <remote_host>
```
3.如果ssh服务未启动,请使用以下命令启动ssh服务:
```shell
sudo service ssh start
```
相关问题
如何解决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"错误。
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 ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)