Skip to content

SSH access to ec2 fails.

0

I can't access ec2. When I connect to console, I get an ssh error. Failed to connect to your instance Error establishing SSH connection to your instance. Try again later.

asked a year ago173 views
2 Answers
3

Hello.

Are you using EC2 Instance Connect to connect to EC2?
In that case, you must meet the prerequisites listed in the following documents:
A common problem is that the security group does not allow the IP address of EC2 Instance Connect.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-prerequisites.html

EXPERT
answered a year ago
EXPERT
reviewed a year ago
1

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")'

answered a year 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.