Skip to content

EC2 Instance Connect Endpoint Connection Failed: Error establishing SSH connection to your instance. Try again later.

0

Each time I'm trying to connect to a «private» instance via Instance Connect Endpoint, Always throws an error saying Error establishing SSH connection to your instance. Try again later.

The instance is using ARM Amazon Linux 2023 - ECS Optimized AMI, in a t4g.2xlarge instance.

I know and checked that the instance is reachable using a bastion, but rather not to have it.

I checked the EICE ENI, it belongs to an SG allowing all traffic from the same SG, also the ENI on the EC2 machine.

The EICE is on the same subnet as the EC2 instance. I think this is the reason of the problem, but in any tutorial I found, that is how it is configured.

The EICE has another SG, allowing traffic from everywhere, but this does not seem to work either.

The ssh key on the instances is ed25519.

What am I doing wrong? How am I supposed to create a EICE inside my VPC to check my ECS instances?

2 Answers
0

When facing the "Error establishing SSH connection to your instance" issue with EC2 Instance Connect, there are several potential causes to investigate.

First, let's check the security group configuration. Even though you've set up security groups to allow traffic between the EC2 Instance Connect Endpoint (EICE) and your instance, you need to specifically ensure that:

  1. The security group attached to your EC2 instance allows inbound SSH traffic (port 22) from the security group associated with the EICE.

  2. The instance must have the EC2 Instance Connect package installed. For Amazon Linux 2023, this should be pre-installed, but it's worth verifying.

  3. Confirm that your EC2 instance is in the "running" state and has passed all status checks. You mentioned that one status check might be failing, which could indicate an OS-level issue preventing connections.

  4. Verify that the SSH service is running on the instance. Sometimes the SSH daemon might not be started or could be misconfigured.

  5. Check that the IAM user or role you're using has the necessary permissions to use EC2 Instance Connect.

  6. Ensure that your VPC and subnet configurations allow proper connectivity between the EICE and your instance.

  7. The fact that you're using an ed25519 SSH key shouldn't be an issue, but you might want to try with an RSA key to rule out any compatibility issues.

For troubleshooting:

  1. Try rebooting your instance if the problem persists.

  2. Consider using AWS Systems Manager Session Manager as an alternative connection method if SSH continues to fail.

  3. Check that the EC2 Instance Connect prerequisites are met for your specific instance type and AMI.

  4. Verify that there are no network ACLs or other network configurations blocking the connection.

Having the EICE in the same subnet as your EC2 instance should be fine and is a common configuration. The issue is more likely related to security group configurations, instance status, or SSH service availability.
Sources
Failed to connect to your instance Error establishing SSH connection to your instance. Try again later. | AWS re:Post
EC2 instance failed to connet | AWS re:Post
Unable to connect to EC2 using EC2 instance connect | AWS re:Post
EC2 Instance Connect cannot connect to my instance ! | AWS re:Post

answered 3 months ago
EXPERT
reviewed 3 months ago
  • I was checking the AMI for Amazon Linux 2023 ECS Optimized, and it does not come with ec2-instance-connect preinstalled, gonna force install and check if that's the problem.

    EDIT: It was indeed the problem. I believe is an error that AWS do not include ec2-instance-connect preinstalled on AL2023 ECS Optimized.

0

Please consider consulting the following documentation about EC2 Instance Connect Endpoint: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-with-ec2-instance-connect-endpoint.html

The "Security groups" page might offer helpful information for troubleshooting your configuration.

AWS
answered 3 months 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.