You are currently viewing How To Connect To An AWS EC2 Instance Without Key Pair

How To Connect To An AWS EC2 Instance Without Key Pair

How To Connect To An AWS EC2 Instance Without Key Pair

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed how to add an EC2 instance to AWS System manager.

https://cloudaffaire.com/how-to-add-an-ec2-instance-to-aws-system-manager-ssm/

In this blog post, we will discuss how to connect to an AWS EC2 instance without key pair using both AWS console from web browser and AWS CLI from command prompt through AWS SSM Session Manager.

What Is AWS SSM Session Manager:

Session Manager is a fully managed AWS Systems Manager capability that lets you manage your Amazon Elastic Compute Cloud (Amazon EC2) instances, on-premises instances, and virtual machines (VMs) through an interactive one-click browser-based shell or through the AWS Command Line Interface (AWS CLI). Session Manager provides secure and auditable instance management without the need to open inbound ports, maintain bastion hosts, or manage SSH keys.

AWS SSM Session Manager Requirements:

There are multiple ways you can connect to your EC2 instance through session manager, for example, you can connect through AWS EC2 console or AWS SSM console or through AWS CLI or using SSH. In this demo, we have covered connections through AWS console and AWS CLI.

  1. One EC2 instance managed by AWS System Manager (SSM Managed Instance). You can follow the below blog posts to configure an AWS EC2 SSM Managed instance.

https://cloudaffaire.com/how-to-install-aws-system-manager-ssm-agent/

https://cloudaffaire.com/how-to-add-an-ec2-instance-to-aws-system-manager-ssm/

  1. AWS CLI installed and configured in your local system (Optional, If you want to connect using AWS CLI). You can follow the blog posts to install and configure AWS CLI.

https://cloudaffaire.com/how-to-install-aws-cli/

https://cloudaffaire.com/how-to-configure-aws-cli/

How To Connect To An AWS EC2 Instance Without Key Pair:

Using AWS Console Through Web Browser:

Step 1: Open your favorite web browser and connect to AWS console.

Step 2: Navigate to AWS EC2 and select the instance you want to connect and click ‘Connect’.

How To Connect To An AWS EC2 Instance Without Key Pair

Step 3: Select ‘Session Manager’ and click ‘Connect’.

How To Connect To An AWS EC2 Instance Without Key Pair

You will get connected to the EC2 instance with root privileges on the web browser. Type exit or click ‘Terminate’ to end your session. Click ‘Close’ when prompted.

How To Connect To An AWS EC2 Instance Without Key Pair

Note: You can also connect from AWS SSM Session Manager.

How To Connect To An AWS EC2 Instance Without Key Pair

Using AWS CLI Through Command Prompt Or Shell:

Step 1: Install SSM Session Manager Plugin for AWS CLI.

Step 2: Start a new session.

You will get connected to the EC2 instance with root privilege on your local terminal where you have executed the above command.

Step 3: Get SSM Session Manager session details.

If you intend to terminate the session using AWS CLI, note down the current active session id

Step 4: Terminate the session.

Hope you have enjoyed this blog post, to get more details on AWS SSM, please refer below AWS documentation

https://docs.aws.amazon.com/systems-manager/index.html

 

This Post Has One Comment

  1. Avatar
    eMarcel

    It should be aws ssm start-session –target
    and not …
    aws ssm start-session –target instance-id “”

Leave a Reply