Several ways to connect an EC2 instance in AWS.

Once the EC2 instance is created the next job for us is to access the instance.

The instance is a server that is running a different operating system, and there are different ways to reach Linux and Windows instances based on OS.

To create Linux based EC2 instance kindly go through the below blog link

https://pawanbhagat.hashnode.dev/creating-linux-ec2-instance

To create a Windows-based EC2 instance kindly go through the below link

https://pawanbhagat.hashnode.dev/how-to-get-started-with-amazon-ec2-windows-instances

There are several ways to connect to an EC2 instance in AWS, depending on your needs and preferences. Here are some of the most common ways:

  1. SSH

You can use Secure Shell (SSH) to connect to your EC2 instance from a terminal window on your local machine. This is a secure way to access your instance, and you can perform a wide range of tasks from the command line.

Step 1:- First we have to create the EC2 instance on AWS ( AWS Linux)

https://pawanbhagat.hashnode.dev/creating-linux-ec2-instance

Step 2:- during creation it's created .pem file which is downloaded to your Local Machine (Linux Based).

Step 3:- Save this key in any one of the directories on the Local System.(from where you have to access the AWS EC2 instance)

Step 4:- Change the permission of that directory

Here I stored the .pem file in keyfile directory

#chmod 755 keyfile/

Step 5:- Change the permission of .pem file

Go inside the keyfile directory where .pem file is present

#cd /keyfile

#chmod 600 <.pem file name>

Step 6:- Copy the IP address of EC2 instance by clicking on instance

Step 7:- Open the terminal of your Local Linux machine

Go inside where the .pem file is present

#cd keyfile

and type below command

where:-

  • ssh: Command to use SSH protocol

  • -i: Flag that specifies an alternate identification file to use for public key authentication.

  • 2march.pem: .pem file

  • ec2-user: Username that uses your instance

  • 3.109.185.133: IP address is given to your instance

We can successfully login into our EC2 instance through SSH from a Local Linux machine using terminal

  1. Remote Desktop Protocol (RDP)

If you're using a Windows instance, you can use RDP to connect to your instance's desktop environment. This allows you to use graphical applications on your instance.

For this kindly refer below blog link

https://pawanbhagat.hashnode.dev/how-to-get-started-with-amazon-ec2-windows-instances

  1. AWS Systems Manager Session Manager

AWS Systems Manager Session Manager is a fully managed service that enables you to manage your Amazon EC2 instances through an interactive one-click browser-based shell or through the AWS CLI. You can also use it to securely manage instances in your on-premises environment.

To connect to a Linux instance using Session Manager using the Amazon EC2 console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Instances.

  3. Select the instance and choose Connect.

  4. For the Connection method, choose Session Manager.

  5. Choose Connect.

  1. AWS CLI

The AWS Command Line Interface (CLI) is a unified tool that allows you to manage AWS services from the command line. You can use the AWS CLI to connect to your EC2 instances and execute commands.

  1. AWS Management Console

You can also connect to your EC2 instance through the AWS Management Console. This is a web-based interface that allows you to manage your AWS resources, including your EC2 instances.

To connect to your instance using the browser-based client from the Amazon EC2 console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Instances.

  3. Select the instance and choose Connect.

  4. Choose EC2 Instance Connect.

  5. Verify the user name and choose Connect to open a terminal window.

  1. Third-party tools

There are also third-party tools available that can help you connect to your EC2 instances. For example, you can use PuTTY, MobaXterm, or WinSCP for SSH connections or Remote Desktop Connection Manager for RDP connections.

Kindly refer to the blog link to connect through putty

https://pawanbhagat.hashnode.dev/creating-linux-ec2-instance

In summary, these are some of the most common ways to connect to an EC2 instance in AWS. You can choose the method that best fits your needs and preferences.