Unable to ssh into my EC2 instance.

0

I am working on a project where i need to ssh into the ec2 instance and one fine day i am unable to connect to it. the problem is i dont have a pem key needed.this is the error i am getting I have trying modifying the inbound rules also but nothing works.. can you help me regarding this

hammad
asked 12 days ago42 views
3 Answers
0
Accepted Answer

You shouldn't need a public/private keypair setup to login to an instance using EC2 Instance Connect.

Was this instance always able to be connected to using Instance Connect before today? Has anything changed in the networking, such as changes to a route table or the presence/absence of an Internet Gateway?

Might be worth checking that the instance itself is healthy, and that the EC2 section of AWS Console is the Status check column showing all checks passed (could be 2/2 or 3/3).

The error message dialogue directs you to https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-prerequisites.html It would be worth going through the list of items on this page.

profile picture
EXPERT
Steve_M
answered 12 days ago
  • Yes i was able to connect to this instance and apparently no changes were made. Its just that I was previously having an error "ran out of memory'", I wonder if that's somehow the reason for for being able to connect to it. The instance is healthy and the status checks are also passed.

0

Hello,

It may also be worth checking to ensure your network connection is not the issue here.

Also, confirming that the instance is still up and running, as well as the firewall rule configuration - security group and NACL, may be useful.

answered 11 days ago
0

Hello,

If you are connecting using an AWS EC2 Instance Connect, you need to allow port 22 to AWS IPs based on your region. In the link, you can search for "EC2_INSTANCE_CONNECT" and note the IP addresses based on your region, then allow port 22 to those IPs in the inbound rules.

Alternatively, you can execute the following curl command to filter and display the EC2 Instance Connect IPs:

$ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.prefixes[] | select(.service == "EC2_INSTANCE_CONNECT")'

profile picture
answered 11 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions