Alibaba Cloud Tech Share - How to Troubleshooting SSH errors - Alibaba Cloud Developer Forums: Cloud Discussion Forums

KUKE
Intern
Intern
  • UID2139
  • Fans0
  • Follows0
  • Posts1
Reads:1488Replies:0

Alibaba Cloud Tech Share - How to Troubleshooting SSH errors

Created#
More Posted time:Feb 28, 2017 0:20 AM
when you can no longer access to your Elastic Compute instance
Read from socket failed: Connection reset by peer

Connection closed by foreign host.
Disconnected from remote host.

There are many reasons this could happen,
from a full disk to an accidental misconfiguration of sshd.
mybe somehow the permissions of the files inside /etc/ssh have changed(chmod -R 755 /etc).
it is possible a Elastic Compute instance will no longer accept SSH connections.
what you can do is to create a new instance and transfer the disk from the old instance.
or you can

    cd /etc/ssh
    sudo chmod 644 ./*
    sudo chmod 600 ssh_host_dsa_key
    sudo chmod 600 ssh_host_rsa_key
    sudo chmod 755 .
    /etc/init.d/ssh restart
Finally the file permissions should look like something

-rw-r--r--.   1 root root   2047 Aug 12  2010 ssh_config
-rw-------.   1 root root 125811 Aug 12  2010 moduli
-rw-------.   1 root root    963 Mar  1 16:02 ssh_host_key
-rw-r--r--.   1 root root    627 Mar  1 16:02 ssh_host_key.pub
-rw-r--r--.   1 root root    382 Mar  1 16:02 ssh_host_rsa_key.pub
-rw-------.   1 root root   1675 Mar  1 16:02 ssh_host_rsa_key
-rw-r--r--.   1 root root    590 Mar  1 16:02 ssh_host_dsa_key.pub
-rw-------.   1 root root    668 Mar  1 16:02 ssh_host_dsa_key
-rw-------.   1 root root   3845 May  7 11:52 sshd_config
After changing the permissions try connecting from xshell, should work fine.
Good Lucky,Sincerely.
Guest