23

I went on to my amazon ec2 successfully and I have been experimenting around. I found it annoying that I needed to always run sudo on everything so what I decided to do was to go to the route directory and change the permissions of everything to write, write, and execute.

I did so doing the following

chmod -R 777 .

I then exited out of the server.

The next time I tried to logon I got

"ssh_exchange_identification: read: Connection reset by peer"

How can I fix this?

Thank you

applecrusher
  • 5,508
  • 5
  • 39
  • 89

5 Answers5

32

My solution is probably trivial, but who knows who it could help:

I simply rebooted my EC2 instance in the browser (AWS -> EC2 Dashboard -> instances -> (select your instance) -> (click the action dropdown) -> Instance State -> Reboot

You may want to give it a minute before you try you ssh connection command again. Hope that helps someone.

Nick
  • 437
  • 4
  • 9
  • 5
    reboot did not help me, I needed to stop the instances and start again to solved the problem. But major problem is that I need to do this every day. Is there any permanent solution? – Devang Aug 05 '17 at 13:10
11

Heavy Server Load

Have also seen this happen when server was under heavy load from for example, brute force attack. Increase the amount of connections sshd can run. http://edoceo.com/notabene/ssh-exchange-identification

bluesky
  • 286
  • 2
  • 9
8

In my case instance stop and start worked.

I simply rebooted my EC2 instance in the browser (AWS -> EC2 Dashboard -> instances -> (select your instance) -> (click the action dropdown) -> Instance State -> Stop

then

I simply rebooted my EC2 instance in the browser (AWS -> EC2 Dashboard -> instances -> (select your instance) -> (click the action dropdown) -> Instance State -> Start

Note:- It takes a while for stop and start, have some patience.

thanks Pranav

Pranav Pathak
  • 179
  • 2
  • 4
  • 4
    Don't use this if your instance is live. This approach will change IPs and you're in for more shock! https://stackoverflow.com/questions/55414302/an-ip-address-of-ec2-instance-gets-changed-after-the-restart – barudo Oct 14 '19 at 23:54
4

As a helpful annotation, I had this case in a shared hosting environment, specifically GoDaddy, and the reason It gave me this error:

ssh_exchange_identification: read: Connection reset by peer

Solution: my local machine's ip had been blocked by GoDaddy, so I had to contact their support, send them a screenshot of the error output from running:

ssh -v user@domain

, and also provide them with my ip. They noticed my ip had been in fact blocked, removed it, and problem solved.

Additionally, you should not have your keys be in a 777 chmod. You should change them to 700.

-1

The reason ssh 22 has disable for EC2 from Security group or IP of system where you are connecting EC2 over ssh port 22. Go to EC2-->Security group and Inbound Port and add ssh port.

Rajeev Rathor
  • 1,830
  • 25
  • 20