Guide to Connecting to an EC2 Instance in AWS

Guide to Connecting to an EC2 Instance in AWS

Amazon Elastic Compute Cloud (EC2) provides scalable computing capacity in the cloud. Connecting to an EC2 instance is an essential part of managing and utilizing its resources. This guide aims to walk you through the process of connecting to an EC2 instance in Amazon Web Services.

Step 1: Launching an EC2 Instance:

  1. Sign in to the AWS Management Console: Log in to your AWS account and navigate to the EC2 Dashboard.

  2. Launch Instance: Click on the "Launch Instance" button to begin the instance creation process.

  3. Choose an Amazon Machine Image (AMI): Select an AMI based on your requirements, such as Linux, Windows, or other specialized images.

  4. Choose Instance Type: Choose the instance type based on the computing power and resources you need.

  5. Configure Instance: Configure additional settings like network, storage, tags, etc.

  6. Configure Security Group: Define the security group settings to control inbound and outbound traffic to the instance.

  7. Review and Launch: Review the instance details and launch the instance.

Step 2: Connecting to the EC2 Instance:

For Linux Instances (using SSH):

  1. Get the Public IP: Once the instance is running, note down its Public IP address from the EC2 Dashboard.

  2. Set Permissions for SSH Key: Ensure that the SSH key pair used during instance creation has the correct permissions (chmod 400 your-key.pem for example).

  3. Connect via SSH: Open a terminal or command prompt and use the following command to connect:

     bashCopy codessh -i path/to/your-key.pem ec2-user@public-ip-address
    

    Replace path/to/your-key.pem with the path to your private key file and public-ip-address with your EC2 instance's Public IP.

How To: SSH to EC2 AWS from Windows 10 CMD or Terminal

For Windows Instances (using RDP):

  1. Retrieve Public IP: Similarly, note down the Public IP address of your Windows instance from the EC2 Dashboard.

  2. Retrieve Administrator Password: Retrieve the auto-generated Administrator password using the key pair file or AWS Systems Manager.

  3. Connect via RDP: Use a Remote Desktop client on your local machine and enter the Public IP address of the instance. When prompted, enter the Administrator username and password.


                        Remote Desktop client.

Using PuTTY (Windows):

  1. Download and Install PuTTY: If you haven't installed PuTTY, download and install it from the official website.

  2. Convert Key Pair for PuTTY: Convert your .pem private key to PuTTY's .ppk format using PuTTYgen (included with PuTTY).

  3. Configure PuTTY Session: Open PuTTY and enter the Public IP of your instance in the "Host Name" field. Under "Connection" -> "SSH" -> "Auth," browse and select the converted .ppk private key.

  4. Connect via PuTTY: Click "Open" to start the SSH connection to your EC2 instance using PuTTY.

PuTTY step 1

Using MobaXterm (Windows):

  1. Download and Install MobaXterm: Download and install MobaXterm from its official website.

  2. Load Private Key: In MobaXterm, go to "Session" -> "SSH" -> "Advanced SSH settings" -> "Use private key" and load your .pem private key.

  3. Start an SSH Session: Create a new SSH session by entering the Public IP of your instance in the "Remote Host" field and the username (ec2-user for Amazon Linux) in the appropriate field.

  4. Connect via MobaXterm: Click "OK" to establish the SSH connection to your EC2 instance using MobaXterm.

MobaXterm v12.4

Conclusion:

Connecting to an EC2 instance in AWS is crucial for managing and utilizing its computing power efficiently. By following these steps, you can establish secure connections using native SSH, PuTTY, or MobaXterm, catering to various user preferences and operating systems. It's essential to manage security groups and permissions effectively to ensure secure access to your instances.