1

I'm trying to SSH into a EC2 instance. It worked previously, but stopped working all of a sudden. Now, I'm getting the error port 22: Operation timed out . My inbound security rules allow all IP addresses for SSH on port 22.

I tried creating a new instance from an image and downloading a new key, but I was still not able to SSH into it the new instance.

What could be the problem here?

My API is running on the server when I try to go to the public ip of the instance. enter image description here

SOLUTION: ufw firewall did not allow ssh. Solution: Locked myself out of SSH with UFW in EC2 AWS

meerkat
  • 932
  • 2
  • 14
  • 38
  • Can you check the instances system log and screenshot? (through EC2 console, right click -> Instance Settings) – Exelian May 18 '20 at 07:48
  • Not sure what to look for in the log, but the log looks ok. It is showing the keys etc. The last line says ip-.... login: Screenshot also has that login statement. – meerkat May 18 '20 at 07:58
  • Are you running the instance in a default VPC or a public subnet of a custom vpc? – Marcin May 18 '20 at 08:06

1 Answers1

0

Ok, so the instances log / screenshot look okay. We'll assume that it's a network issue somewhere. First step would be to create an AWS Flowlog for your VPC. Flowlogs allow to see if traffic is blocked by a security group or something like that. If your instance is not receiving traffic due to a SG you'll see it in a flowlog.

To create a flowlog go to the VPC console > VPC's and select your VPC. IN the lower frame go to the flowlog tab and select create a flowlog. I would suggest you filter for "REJECT" only because otherwise it'll fill up fast. You can publish it to CloudWatch and take a look at it.

Flowlogs are delivered per network interface, so you'll need to check your EC2 instance for the relevent ENI-id.

Exelian
  • 5,749
  • 1
  • 30
  • 49