By Abdullah Haroon – Student | Cloud Practitioner| AWS Learner
What You’ll Learn
By the end of this guide, you’ll:
- Understand what Amazon EC2 is
- Launch your first virtual server using AWS Free Tier
- Connect to it securely via SSH
- Install a basic web server
- Apply essential security practices for beginners
What is EC2?
Amazon EC2 (Elastic Compute Cloud) is AWS's virtual server service. It allows you to rent virtual machines (VMs) in the cloud where you can run applications, host websites, or learn Linux—all without buying hardware.
Think of it as your own personal server, available globally, just a few clicks away.
Common use cases:
- Hosting websites & web apps
- Deploying APIs and backend services
- Machine learning & data processing
- Practicing Linux/DevOps tools
What You Need
- A free AWS account — Create one here
- A stable internet connection
- Basic knowledge of using terminal/command prompt
Step-by-Step guide: Launching Your First EC2 Instance
Step 1: Log in to the AWS Console
Go to https://console.aws.amazon.com/ and sign in.
Choose a region (e.g., US East - N. Virginia) at the top-right.
Step 2: Navigate to EC2
- Click on Services
- Search for EC2 and select it
- In the EC2 Dashboard, click Launch instance
Step 3: Configure Your EC2 Instance
Name
-
Name:
MyFirstEC2
AMI (Amazon Machine Image)
- Choose: Amazon Linux 2023 (Free tier eligible)
Instance Type
- Choose: t2.micro
Key Pair
- Create a new key pair:
ec2-key-abdullah
- Select .pem
- Download and store the file securely (you’ll need it to SSH)
Network Settings
- Create a new security group
- Allow SSH (Port 22) — Source: “My IP”
- (Optional) Allow HTTP (Port 80) if installing a web server
Storage
- Default 8 GB is fine
Click Launch Instance
Congratulations! Your instance is launching.
Step 4: Access Instance & Copy Public IP
- Go to Instances > Running Instances
- Wait until instance status is running
- Copy the Public IPv4 address
Step 5: Connect to EC2 via SSH
On Linux/macOS:
chmod 400 ec2-key-abdullah.pem
ssh -i ec2-key-abdullah.pem ec2-user@<your-public-ip>
Step 5 (continued): Connect on Windows (Git Bash or WSL)
Same command as above:
chmod 400 abdullah-key.pem
ssh -i abdullah-key.pem ec2-user@<your-public-ip>
Step 6: Install Apache Web Server
Once logged in via SSH:
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
Now open your public IP in a browser — you’ll see the Apache test page!
Security Best Practices
Common Mistake | Best Practice |
---|---|
SSH open to all IPs (0.0.0.0 ) |
Restrict to My IP only |
Sharing .pem file with others |
Keep it private and secure |
Keeping unused instances running | Stop or terminate when not in use |
Using root account always | Use IAM roles and least-privilege access |
Troubleshooting Tips:
Permission denied (publickey)
chmod 400 abdullah-key.pem
SSH timeout or connection refused
- Ensure Port 22 is allowed in your EC2 Security Group
- Confirm you're using the correct public IP from the EC2 Console
Webpage not loading
- Add a rule in your Security Group to allow HTTP (Port 80)
What You Achieved
You have successfully:
- Launched a virtual server (EC2 instance)
- Connected via SSH securely
- Installed a working Apache web server
- Followed essential cloud security steps
You’ve taken your first big step into the AWS Cloud! ☁️
Let’s Connect!
I’m sharing my AWS learning journey through beginner-friendly blogs.
Follow me for more hands-on tutorials and free-tier projects.
- LinkedIn: https://www.linkedin.com/in/muhammad-abdullah-haroon-b49478271/
- Dev Blog: dev.to: abdullah_haroon_092cf10d3
Top comments (0)