0

When I try to connect to ec2 through my pem file it worked fine. Once I connected to ec2 and exited from terminal, from next time it's giving error

ssh_exchange_identification: Connection closed by remote host

When I again tried to connect, I got the following error

ssh_exchange_identification: read: Connection reset by peer

I have rebooted the instance and now I am getting the following error

ssh: connect to host MY-IP port 22: Operation timed out

I have seen so many solutions. Most of them messed up with security groups. But I have correct security group.

INBOUND ssh 22 0.0.0.0/0

OUTBOUND All Trafic All All 0.0.0.0/0

Even then I am getting the same error.

I have tried ssh -v -i XXX.pem ec2-user@XX.XX.XX.XX

ouput is

OpenSSH_7.6p1, LibreSSL 2.6.2 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug1: /etc/ssh/ssh_config line 52: Applying options for * debug1: Connecting to my_ip port 22. ssh: connect to host my_ip port 22: Operation timed out

  • 1
    It sounds to me like the SSH server on the remote host is experiencing issues of some kind. I've seen various issues cause the SSH daemon to simply stop accepting connections, or unexpectedly close open ones. Best course of action is to launch a recovery instance, attach the faulty instance's EBS volume to your recovery instance, and inspect the logs. – dannosaur Dec 24 '18 at 8:56
  • 1. You should post the full debug error (and use editor to mask out the ip and server name) and format it in code sample. 2. Open your AWs console and look for the ssh connection command, e.g. try ssh -i xx.pem ec2-user@ec2-xx-xx-xx-xx.compute-x.amazonaws.com. – mootmoot Dec 24 '18 at 9:09
  • Is your instance running? And does it have the same IP address? – Michael Hampton Dec 24 '18 at 15:07
  • yes. I have checked all those basic things. – Kodanda Rama Durgarao Poluri Dec 25 '18 at 4:15
  • I experienced the same issue (I believe) last night. My question is here serverfault.com/questions/947600/… – lonelyloner Jan 4 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.