ssh_exchange_identification: Read: Connection Reset By Peer {Solved}

The ssh_exchange_identification: read: connection reset by peer is very rare, but you can run into it if you are trying to ssh into any Unix server. It won’t matter if you are using Windows with Cygwin to gain access to macOS or Ubuntu with the terminal to the ssh into the arch, CentOS or fedora. And since ssh is universal across Limex and Unix, ssh_exchange_identification: read: connection reset by peer error tends to occur at any time when the remote server removes your connection without your sanction.

Contents

How to Fix ssh_exchange_identification: Read: Connection Reset By Peer

Solution 1: Check the Hosts.deny File

In case you possess administrative privileges on the server or a way to gain it’s accessed then till now the easiest way to resolve ssh_exchange_identification: read: connection reset by peer error is to navigate to a prompt logged directly into server’s computer and then have a look at the Hosts. Deny file.

You have to type: sudo nano/etc/hosts.deny

on the server to check if your machine is listed as banned for some reason.

If this is the case, then this must be a mistake, and you can easily remove it and then reconnect through ssh on the other machine. Or else, check to ensure that there are no weird wildcards that could have forbade your machine from getting connected. A fresh file that has nothing but the default text that had been added by the server’s distribution would not be your culprit, however, in the majority of cases.

sudo/etc/host.allow

If you would like to add your remove login normally to ensure that it will connect. It is to be noted that it is rarely necessary, but if you do so and add then, you are required to follow the informational text that distribution provided.

Solution 2: Changing ssh Configuration Options

If In case you are unable to get to the remote server or if the previous method failed to fix your problem then you should clear out the old ssh configuration files and then see if it resolves the issue after an update. If it does not, then add the v- option to ssh and then try to connect again if you get an error message, then try adding -c aes256-ctr to the ssh command and see if this solves ssh_exchange_identification: read: connection reset by peer issue. This will shorten the cypher list and enable you to connect you to the server you have been trying to ssh into as this shortens the packet size in turn.

Some of the users have noticed that it is especially useful when the troubleshooting of some sort of cisco- branded equipment as some pieces of the server hardware by default require smaller packet sizes. Add -c aes256-ctr to the usual ssh command and it should enable you to get in.

Solution 3: Overriding Accidental IP Bans

In case you had tried to get logged in numerous times before but got denied, they may be your server mistook you for some bad IP address. This usually happens if the user keeps retrying to connect during troubleshooting, which is an obvious response but it looks like an attack to fail2ban subroutine.

To ensure that this did not happen, Run sudo IP tables -L-line- a number from remote connect and then look for your IP address. You will possibly find that there is any number of unrelated connections. You should just ignore them.

Once you have detected the problem, Run IP tables-D followed by an offending chain and the chain number to avoid you from getting banned by your software again. This should prevent any further problems, but if you still face some issue then you should edit the file given below:

/etc/file2ban/jail.conf

Load this up in your favourite text editor and more than likely vi or nano, as root. You will probably wish to run something like:

Sudo nano/etc/fail2ban/jail.conf

And look for a line which reads ignore IP. Then add your IP address to this line to permanently block fail2ban from adding your IP address to any of the blocklists.

Different Linux distribution does things differently, but the made changes should work instantly in most of the cases.

Read Next:

Conclusion

ssh_exchange_identification: read: connection reset by peer error occurs rarely. It is generally due to some sort of misunderstanding by the software due to which your connection gets removed or banned. Diagnose the root of the problem correctly and follow the instructions given above with the alert mind. Or you can start with the first method and work your way down until one method works. Hope that the guide proves useful to you.