Question

ssh_exchange_identification: read: Connection reset by peer Ask Question

I have a droplet on Digital Ocean. Its credentials are shared with one of my friend. We used to connect to it via ssh as:
ssh root@IP_Address Now due to lack of concentration we did a mistake by running the following command while on the server: sudo chmod -R 777 / due to which server is not connecting anymore via anything (SSH/SCP/FTP/…) and is giving the following error: ssh_exchange_identification: read: Connection reset by peer
Following is the output of ssh root@IP_Address -vv

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug2: resolving "IP_Address" port 22 
debug2: ssh_connect_direct: needpriv 0 
debug1: Connecting to IP_Address [IP_Address] port 22. 
debug1: Connection established. 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_rsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_rsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_dsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_dsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_ecdsa type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_ecdsa-cert type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_ed25519 type -1 
debug1: key_load_public: No such file or directory 
debug1: identity file /home/talha/.ssh/id_ed25519-cert type -1 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 
ssh_exchange_identification: read: Connection reset by peer 

Kindly help me ASAP as I don’t have latest backup of hosted projects and databases.
Thank you in advance!

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

To fix this, you should have access to droplet. One way to access your droplet is to go to your droplet and then click “Access”. If you remember the password for respective droplet, click on “Launch Console”. Once console is launched, enter username and then password and it’d allow you to access server(if entered username and password are correct). On your server, now check if ssh is allowed or not by firewall rules. You can check it by following command:

sudo ufw status

If ssh is allowed then, you should see following lines on terminal:

22/tcp                     ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)

If you don’t find these 2 lines, it means ssh connection is not allowed and you need to set rule to allow that. It’s simple though. Just run following command:

sudo ufw allow ssh

After allowing, you should confirm if it’s added to rules by sudo ufw status. After following these steps, you should be able to connect via ssh again. This is how I fixed the exact same issue when I faced at my end. I hope it’d be helpful.

As @Scevola said, unfortunately the best course of action would be to create a new Droplet and migrate your data over. It is technically possible to fix the issue and restore the permissions without creating a new Droplet, but the amount of effort required to so to properly is simply not worth it.