ssh_exchange_identification read connection reset by peer SSH error is something you may see in your terminal when trying to log in to a remote host or when your session expires on a Linux system. In this tutorial, we will go over a few different causes for this error and show you how to troubleshoot the connection on your system. Using one of our methods below will hopefully remedy the error and allow you to log in via SSH or maintain your current session.
In this tutorial you will learn:
- How to fix the
ssh_exchange_identification read connection reset by peerSSH error message on Linux
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Solutions for ssh_exchange_identification read connection reset by peer
The error occurs when trying to log in to a remote host via SSH on Linux or when you are already logged in but the session expires or otherwise kicks you out. There are a few different things that could be causing the errror, and it is impossible to know which one is affecting your session until you run through the methods below.
We have listed some of the most common solutions to this problem below. We recommend that you try them one by one until your issue is resolved.
- One of the best ways to get started is to try an SSH login from a different host with a separate IP address. Does that host get denied too? This will tell you if the remote server is denying connections to all hosts or just yours.
- If your connection is being reset after it has already been established, there is a good chance that you are reaching the inactivity timer after going idle for a few minutes in your session. To check the timeout setting or adjust it, find the following lines inside of your
$ cat /etc/ssh/sshd_config | grep -i ClientAlive
ClientAliveCountMaxsettings will need increased in order for there to be any change.
- Check the
/etc/hosts.denyfile on the server to make sure that your system’s IP address or domain name is not listed in there.
$ cat /etc/hosts.deny
- Another thing you can do is check the SSH log file to see if there are any hints about what is causing the error.
$ tail /var/log/auth.log
- If there are many users logging in via SSH to the server, check to make sure that the SSH configuration file allows for an appropriate number of simultaneous connections. If you find this number to be too low, consider increasing it.
$ cat /etc/ssh/sshd_config | grep MaxStartups
- Check to make sure that there is no rule blocking your connection in the server’s firewall. The syntax for doing this will vary in iptables, ufw, firewalld, etc.
# iptables -L
- Have you tried rebooting? It is an old adage, but rebooting the system is a common way to fix many issues. This is especially true if memory fragmentation or something similiar is the culprit. Sometimes this may only be a temporary solution.
In this tutorial, we saw several methods that can be used to resolve the
ssh_exchange_identification read connection reset by peer error message on a Linux system. Since there are a variety of potential causes for this error, we have covered numerous methods in this tutorial on how to fix it. Running through these methods should give you an idea of what the cause of the error is on your system, and will hopefully prevent it from happening again.