Step-by-Step Guide on How to Create an EC2 Instance on AWS
Amazon Elastic Compute Cloud (EC2) is one of AWS’s most popular services, that lets you launch and manage virtual servers in the cloud. Whether you're hosting a website, running a database, or testing software, EC2 provides scalable, secure, and customizable computing capacity.
This guide walks you through creating a basic EC2 instance using the AWS Management Console.
Prerequisites
- An AWS account (sign up if you don’t have one)
- Basic familiarity with cloud concepts
- (Optional) SSH key pair for secure remote access
Step 1: Sign in to the AWS Management Console
- Go to https://console.aws.amazon.com.
- Sign in with your AWS credentials.
Step 2: Navigate to the EC2 Dashboard
- In the AWS Console, search for EC2.
- Click EC2 to open the EC2 Dashboard.
---
Step 3: Launch an Instance
- Click Instances in the left navigation pane.
- Click the Launch Instance button.
Step 4: Configure Instance Basics
On the Launch an Instance page:
-
Name: Enter a name for your instance (e.g.,
MyFirstInstance
). - Application and OS Images (AMI): Choose an Amazon Machine Image (AMI). For beginners, the Amazon Linux 2023 AMI (Free Tier eligible) is a good choice. Note: If you need Windows or another OS, select the corresponding AMI.
-
Instance Type: Choose the instance type (e.g.,
t2.micro
for Free Tier eligibility).---
Step 5: Create or Choose a Key Pair
- In Key pair (login), choose an existing key pair or create a new one.
- To create a new one:
- Click Create new key pair.
- Enter a name.
- Choose the format (e.g.,
.pem
for Linux/Unix). - Download it securely.
Important: Keep this file safe. You’ll need it to SSH into your instance.
![]()
Step 6: Configure Network Settings
- AWS will auto-select a VPC and subnet by default.
- Under Firewall (security groups):
- Create a new security group or choose an existing one.
- For SSH access, add a rule:
- Type: SSH
- Port: 22
- Source: Anywhere (0.0.0.0/0) or My IP (more secure).
⚠️ Warning: Opening SSH to “Anywhere” is less secure. Restrict it to your IP whenever possible.
✅ Best Practice: Avoid0.0.0.0/0
for production. Always limit to trusted IP addresses.
Step 7: Add Storage
- The default root volume is usually sufficient (e.g., 8 GiB gp2).
- You can increase the size or add additional volumes if needed.
Step 8: Review and Launch
- Review your instance configuration.
- Click Launch Instance.
Step 9: View and Connect to Your Instance
- Click View Instances after launching.
- Wait until Instance State shows running.
- Note the Public IPv4 address of your instance.
Step 10: Connect to Your Instance via SSH
Open your terminal and run:
Set the correct permissions on your key
chmod 400 /path/to/your-key.pem
Note: SSH username varies by AMI:
- Amazon Linux:
ec2-user
- Ubuntu:
ubuntu
- Other distributions: Check AWS documentation for the correct username.
Example SSH Command
ssh -i /path/to/your-key.pem <your-user-name>@<your-ip>
🎉 Congratulations! You’ve launched your first EC2 instance and connected via SSH. You can now deploy applications, host websites, or explore AWS features.
Top comments (0)