What You Will Learn
Beginner
- How to launch an EC2 instance
- How to configure security groups
- How to connect via SSH
EC2 (Elastic Compute Cloud) is AWS virtual server service. You rent a virtual machine by the hour (or second) and run anything on it.
Key Concepts
| Term | Meaning |
|---|---|
| AMI | Amazon Machine Image — the OS template (Ubuntu, Amazon Linux, etc.) |
| Instance type | Size of the VM (t2.micro = 1 CPU, 1GB RAM — free tier) |
| Security group | Firewall rules (which ports are open) |
| Key pair | SSH key for connecting to the instance |
Launch Steps
Go to EC2 -> Launch Instance
Choose AMI: Amazon Linux 2 (free tier eligible)
Choose instance type: t2.micro (free tier)
Configure: leave defaults, enable auto-assign public IP
Add storage: 8 GB (default)
Create security group: allow SSH (port 22) from your IP
Create or select a key pair (download .pem file)
Click "Launch instance"
Connect via SSH
Terminalbash
# Set permissions on your key
chmod 400 my-key.pem
# Connect
ssh -i my-key.pem ec2-user@PUBLIC_IP
# Inside the instance
uname -a
sudo yum update -yPractical Exercise
Launch a t2.micro EC2 instance with Amazon Linux 2
Connect via SSH using the .pem key
Run
uname -a inside the instanceRun
sudo yum update -yTerminate the instance when done (to avoid charges)
Key Takeaways
- EC2 = virtual server, pay per hour/second.
- AMI = OS template. Instance type = size. Security group = firewall.
- Free tier: t2.micro, 750 hours/month for 12 months.
- Connect via SSH:
ssh -i key.pem ec2-user@IP - ALWAYS terminate instances when done — running instances cost money.
Comments
Comments
Post a Comment