Creating a Ubuntu VM (instance) on AWS using EC2 and accessing it using MobaXterm
Tags: aws, jenkins, ec2, devops
Published: 2024-07-08 07:49:26

Step 1: **Create an EC2 Instance on AWS**
Sign In to the [AWS Management Console](https://aws.amazon.com/console/):


Step 2: **Navigate to EC2 Dashboard:**

From the AWS Management Console, click on "Services" in the top left corner, then select "EC2" under the "Compute" category.


Step 3: **Launch an Instance:**

In the EC2 Dashboard, click the "Launch Instance" button.
Choose an Amazon Machine Image (AMI):

Select an AMI that suits your needs. For this example, let's select "UBUNTU".


Step 4: **Choose an Instance Type:**

Select an instance type based on the compute, memory, and storage requirements of your application. The t2.micro / t2.meduim instance type is a common choice for small applications and is eligible for the free tier.

Step 5: **Configure Instance Details:**

Configure the instance details according to your requirements. For a basic setup, you can leave the default settings.


Step 6: **Add Storage:**

Configure the storage for your instance. The default settings are usually sufficient, but you can add more volumes or change the volume type as needed, like 20-30.

Step 7: **Add Tags:**

Add tags to help you manage and identify your instances. Tags are key-value pairs that can be used for organization, automation, and cost allocation.

Step 8: **Select a Key Pair:**

Select an existing key pair or **create a new key pair**. A key pair is used for secure SSH access to your instance. Download and save the key pair file (.pem) securely, as you won't be able to download it again.

Step 9: **Configure Security Group:**

Create a new security group or select an existing one. Ensure that the security group has a rule allowing SSH traffic (port 22) from your IP address or a range of IP addresses. Example rule:
Type: SSH
Protocol: TCP
Port Range: 22
Source: My IP (or a custom range of IP addresses)

Step 10: **Review and Launch:**
Review your instance configuration and click the "Launch" button.
Click "Launch Instances" to create your EC2 instance. You'll see a confirmation page with the instance ID.

**<u>PART 2::</u>**
**Access Your EC2 Instance Using MobaXterm**


**Download and Install MobaXterm:**

If you don't already have MobaXterm installed, download and install it from the official [MobaXterm](https://mobaxterm.mobatek.net/) website.

**Open MobaXterm:**
Launch MobaXterm on your local machine.


**Configure the SSH Session:**

Click on the "Session" button in the top left corner.
Select "SSH" from the session type options.
Enter Remote Host Information

In the "Remote host" field, enter the public IP address of your EC2 instance. This information can be found in the EC2 Dashboard under "Instances".

**Specify Username:**

Enter the username for your AMI. For ubuntu, default username is ubuntu For Amazon Linux 2, the default username is ec2-user.

**Advanced SSH Settings:**

Click on the "Advanced SSH settings" tab.
In the "Use private key" section, click the "Browse" button and select the .pem key pair file you downloaded when creating your EC2 instance.

**Start the SSH Session:**

Click "OK" to start the SSH session. MobaXterm will use the specified private key to authenticate and establish an SSH connection to your EC2 instance.

**Thank You. **