How to fix “kex_exchange_identification: Connection closed by remote host” error

Oftentimes, when dealing with our own custom network, we face many different problems. To make our network work, it is essential that all the devices attached to this network are configured correctly. Different errors occur when more and more devices are added to a network. When the error “kex_exchange_identification Connection Closed by Remote Host” pops up, it indicates that a previously established connection has been interrupted for some reason.

This post demonstrates the possible reasons and also provides the solutions to these reasons.

How to Fix “kex_exchange_identification Connection Closed by Remote Host” problem?

There exist a couple of different reasons that can invoke this problem on your system. This section will provide a detailed guide on these major reasons and also teach you how to fix these issues.

Reason 1: Server Went Idle

This interruption between the client and the SSH server occurs when you idle for a while. The firewall on your system can cut off your idle connection. The OpenSSH server needs to be accessed to adjust the settings.

Solution

To ensure that this issue does not occur, it is important to make sure the server does not go idle. We can do this by accessing the OpenSSH-server and adding the following command:

ssh user@server -o ServerAliveInterval=300

This should refresh your server every 5 minutes.

Reason 2: Defective/Faulty Devices

Whenever you add a new device or equipment to your network, you need to be absolutely sure that all of its aspects are working correctly. Even one defective device can cause the entire system to face this problem of “kex_exchange_identification Connection Closed by Remote Host”.

Solution

To fix the reason mentioned above, we need to make sure that any new devices or equipment that we add to our network system is working perfectly without any major bugs. It is also essential to double-check whether the device has been configured correctly or not. Once it is configured perfectly, it can fit into the system without errors.

Conclusion

The two main causes of the “kex_exchange_identification Connection Closed by Remote Host” error are the interruption at the Server/Client or because of faulty devices. We can configure and fix our devices and add “keepalive” statements to the server to prevent it from going idle. This post has demonstrated to you some possible causes and their fixes to the problem.