Today we are going to discuss one of the rare problems that is ssh_exchange_identification: read: connection reset by peer. This error usually occurs when you try SSH into UNIX server. Even if you are using Windows with cygwin to get into Macos with terminal to SSH into Arch, CentOS and Fedora. SSH is universal so it can come up and disturb you any time and remote server resets everything without taking your permission into consideration. But don’t worry you have come to right place. We will be discussing steps to come out of this troublesome problem.
How to Fix SSH_Exchange_Identification: Read: Connection Reset by Peer Error
Method #1 Check the Hosts.deny File
If you are already using the administrative services and knew methods to access it then this solution might be the easiest for you to get rid of the ssh_exchange_identification: read: connection reset by peer problem.
Step 1: So what you have to do is to log into the server’s computer and search for hosts.deny file there.
Step 2: Open the above said file.
Step 3: Write to check if your machine has not been banned from the usage.
Step 4: If this is the case then it might be due to mistake which can be easily corrected.
Step 5: You can remove it and then reconnect using SSH of the machine. A fresh empty file with some text will be added by the server’s distribution which doesn’t effects much.
Step 6: You can also use your host correctly if you want to add remote login on your own. Make sure that if you are adding it on your own then you must follow the informational text provided by the company.
Step 7: After you write your host correctly then press Ctrl + O to save and then Ctrl + X to close the app. With this you will be able to SSH into the server.
Method #2 Change SSH Configuration Options
If the first method didn’t work out for you then you can try this method. Just follow the below-mentioned steps in order to proceed.
Step 1: Delete your of ssh files. Add the -v option to your ssh and try to reconnect.
Step 2: If you are still getting error messages then write -c aes256- ctr in your ssh command line and check by reconnecting.
Step 3: This step shortens the cipher list and connects your server with the ssh and removing your problems away.
Method #3 Override Accidental IP Bans
If you are continuously trying to login into that and getting denied each time then the server could have taken your IP address wrongly. This problem occurs mostly when you keeps on connecting again and again even during troubleshooting. It looks like an attack to fail2ban subroutine. But we are here to rescue you from this problem.
Step 1: First type sudo iptables -l – line number from the remote and try to search for your IP address there. You can find other unrelated threads which you can ignore easily.
Step 2: After you find the problem the next task is to run iptables- D with the offending chain. You need to enter chain number also to prevent yourself from being banned.
Step 3: If you write /etc/fail2ban/jail.conf then you can easily make modifications in the file.
Step 4: Next step would be to load this as root and look for a line that contains ignoreip. Then you must add your IP address there to block fail2ban service.
We started with checking the hosts.deny file and then changing the ssh settings and in the last we override accidental IP Bans to solve the problem. We hope all the above said methods works for you. If you have any suggestion or any other method other than these please feel free to contact us.