How to Launch and Connect to an AWS EC2 Instance (with SSH)
Okoye Genevieve

Okoye Genevieve @_eve_

About: Cloud & DevOps Engineer. Network Engineer. Designs & deploys robust, scalable cloud infra. Solutions: AWS, Azure, GCP. Implements DevOps. Linux & API Security pro. Connects globally.

Location:
Lagos, Nigeria
Joined:
May 22, 2025

How to Launch and Connect to an AWS EC2 Instance (with SSH)

Publish Date: Jun 9
0 0

Image description
This post will guide you through the process of launching an Amazon EC2 (Elastic Compute Cloud) instance and securely connecting to it using SSH from your local machine. EC2 instances are virtual servers in the AWS cloud, providing scalable compute capacity.

Our Goal:

Our objective is to launch an EC2 instance within a VPC and subnet, then establish an SSH connection to it from our local system administrator's machine using a private SSH key. We'll configure a security group to allow SSH access on port 22.
Image description

The first step in the AWS Management Console is to locate the EC2 service.

Image description
Image description
After selecting the EC2 service, you will be directed to the EC2 Dashboard. From here, we will begin the process of launching a new virtual server.

Image description

Configure Instance Details and Key Pair

In the launch wizard, after selecting your desired AMI and instance type, you will need to create a new key pair (highlighted by the arrow). This key pair is essential for securely connecting to your instance later via SSH.

Image description
When you'er done with your configuration which is to choose the OS, the CPU, stoage... then you can go over to the next step, mind you that this method of creating an instance varies depending on the workload of your project.

Image description

Verify Instance Launch and Access Security Groups

After successfully launching your instance, you'll be redirected to the EC2 Instances dashboard.

Focus Area: The arrows indicate two important things:

Your newly launched instance (e.g., "front-end server") is now listed and in a "Running" state.
The left navigation panel shows "Security Groups" under "Network & Security." We'll navigate here to review or modify the security rules that govern access to your instance.

Image description

Review and Edit Security Group Inbound Rules

You are now on the Security Groups details page, specifically viewing the rules associated with the security group created during your instance launch.

Focus Area: The red arrow clearly points to the "Edit inbound rules" button. This is where you can modify which types of traffic (like SSH, HTTP, HTTPS) are allowed to reach your EC2 instance from external sources. We'll proceed to edit these rules.

Image description

Confirm or Adjust SSH Inbound Rule Source

On the "Edit inbound rules" page, you can see and modify the existing rules.

Focus Area: The red arrow highlights the "Custom" source field, specifically showing your public IP address (e.g., 154.120.95.81/32). This confirms that SSH (Port 22) traffic is allowed only from your machine's IP. While "My IP" automatically populates this, you could manually enter a specific IP address range (CIDR block) or choose other options like "Anywhere" (not recommended for SSH) if needed. Ensure this rule is correctly configured for your connection.

Image description

Retrieve Your Instance's Public IP Address

After confirming your security group rules, the last piece of information you need to connect to your EC2 instance is its public IP address.

Focus Area: Back on the EC2 Instances dashboard, locate your running instance. The red arrow points directly to the "Public IPv4 address" column. This is the IP address you will use to establish an SSH connection from your local machine. Copy this IP address.

You now have all the necessary information to connect to your EC2 instance using an SSH client like MobaXterm and the private key you downloaded
Image description

Connect to Your EC2 Instance via SSH

With your EC2 instance running, its security group configured to allow SSH from your IP, and your public IPv4 address copied, you are now ready to connect!

What you'll need:

Your Private SSH Key: The .pem file you downloaded in Step 4.
The Public IPv4 Address of your EC2 instance (from Step 9).
SSH Client: (e.g., MobaXterm Professional, as shown in your architecture, or PuTTY, OpenSSH on Linux/macOS).
Default Username: For Amazon Linux AMIs, it's ec2-user. For Ubuntu, it's ubuntu. For others, consult the AMI documentation.
Image description
Click on "Session".
Choose "SSH".
Enter the "Remote host" (your Public IPv4 address).
Specify the "Username" (e.g., ec2-user or ubuntu).
Under "Advanced SSH settings", check "Use private key" and browse to your .pem file.
Click "OK" to establish the connection.
Once connected, you'll have command-line access to your brand-new EC2 instance in the cloud!

Conclusion

Congratulations! You have successfully launched an Amazon EC2 instance and securely connected to it using SSH. You've learned how to:

Navigate the AWS EC2 console.
Launch a virtual server.
Create and manage SSH key pairs for secure access.
Configure security group rules to control network traffic.
Retrieve the public IP address of your instance.
Connect to your instance using an SSH client.
This EC2 instance now serves as a powerful foundation for hosting web applications, running backend services, or performing various computational tasks in the cloud. Remember to always follow best practices for security, such as restricting SSH access to known IPs and regularly reviewing your security group rules.

Feel free to explore further configurations and services within AWS to expand the capabilities of your cloud infrastructure!

Comments 0 total

    Add comment