🔗🌟Unlocking EC2 Connectivity: A Guide to Accessing Instances Without a Key Pair!🚀

Krishnendu Bhowmick
3 min readDec 24, 2023

--

Encountered the challenge of misplacing your EC2 key pair? Worry not! Explore this fail-safe guide that ensures seamless connection to your EC2 instance sans the necessity of a key pair. 🔐💻 Unlock the solution here!

For each newly created EC2 instance, the selection of a key pair is pivotal for SSH access. 🔑❓ But what if you find yourself without the key pair? 🤔 Fret not, as I’ve got you covered with a robust solution! 🛡️💻

You’ve landed in the right spot for the fix. Discover how to establish a connection with an EC2 instance even in the absence of a Key Pair. In this comprehensive step-by-step blog post, I’ll guide you through the process, ensuring a secure and stress-free connection. Say goodbye to concerns about lost keys or compromised security. Let’s delve into the solution:

1. Essential Requirements:

  • Security group configured with port 22 for Linux EC2 or 3389 for Windows EC2 instance.
  • Active EC2 instance.
  • VPC endpoint.

2. Establishing a VPC Endpoint:

To ensure seamless functionality, the VPC endpoint must be established within the VPC housing the targeted EC2 instance.

Now, let’s delve into the process of creating the VPC endpoint.

Before proceeding, make a note of the VPC in which your EC2 instance is currently deployed.

Now go to the AWS VPC console >> Endpoints >> Create endpoint

Enter the Name of the VPC endpoint: test-endpoint

Service Category: EC2 Instance Connect Endpoint

Choose the VPC ID of the EC2 instance.

Specify the security groups to associate with the endpoint network interface. The security group rules control the traffic to the endpoint network interface from resources in your VPC.

Select the subnet in which to create the endpoint.

Note: You might create the endpoint in any AZ within the region*

The initial status would be pending. Please wait until it becomes Available.

Once the Endpoint becomes available, Proceed to connect the EC2 instance.

3. Connecting the instance using the VPC endpoint

Navigate to the AWS EC2 console.

Select the EC2 instance to connect with >> Click Connect

Make sure the instance you are connecting is correct.

Connection Type: Connect using EC2 Instance Connect Endpoint

Username: ec2-user for Amazon Linux or ubuntu for Ubuntu OS

Max Tunnel duration: 3600 (default) — SSH access is open and active till this time

EC2 Instance Connect Endpoint — Select the endpoint that we have created “test-endpoint”

Click on Connect

You will see establishing a connection and then connected.

Wow!! You are connected to the EC2 instance without a keypair.

Thank you for reading this article.

--

--

Krishnendu Bhowmick

Site Reliability Engineering | Devops Practitioner | Open Source Advocate | Cloud Enthusiastic