Linux – SSH Connection Error : ssh_exchange_identification: read: Connection reset by peer

linuxssh

When I tried to connect to the server via SSH, I'm getting the following error,

[root@oneeighty ~]# ssh -vvv -p 443 root@xxx.xxx.xxx
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to xxx.xxx.xxx [IP] port 443.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
ssh_exchange_identification: read: Connection reset by peer

I have checked the SSH configuration on server and client and there are no issues.

Restarted the SSH Service on Server and then restarted the server/client, but the issues is not resolved.

Best Answer

This can be a result of number of things.

Few things you can quickly try are as follows,

  • Look in /etc/hosts.deny for any entry like sshd: ALL
  • Perhaps, add sshd: ALL to /etc/hosts.allow

  • It is possible that your SSHD's HostKeys are corrupt. They're present in /etc/ssh/ directory. You may delete them and restart sshd and it shall re-generate them. In case it gives an errors, please use the following commands

    $ ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
    $ ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
    $ ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
    $ /etc/init.d/sshd start