Security Groups & Key Pairs π β
Welcome back, cloud cadet! π€οΈ Now that your EC2 instance is launched, itβs time to lock the doors and keep your cloud palace safe.
In EC2, this is done using Security Groups and Key Pairs. Donβt worry, itβs easier than remembering your Wi-Fi password π .
Security Groups β Your Cloud Firewall π₯ β
Think of a Security Group as a magical firewall around your EC2 instance:
- It decides who can enter and who gets blocked
- You can allow traffic only from specific IPs or networks
- Each EC2 instance can have one or more security groups
Common Rules β
Protocol | Port | Who Can Access | Fun Analogy |
---|---|---|---|
SSH | 22 | Your IP only | Secret door for Linux π±οΈ |
RDP | 3389 | Your IP only | Windows VIP entrance πͺ |
HTTP | 80 | Everyone | Public lounge π |
HTTPS | 443 | Everyone | Secure VIP lounge π |
Pro tip: Only open ports you really need. Leaving everything open = inviting hackers to your cloud party π΅οΈββοΈ
Key Pairs β Your Magic Key ποΈ β
A Key Pair is like a private key for your instance:
- Public key β AWS keeps it on the instance
- Private key β You keep it safe on your computer (.pem file)
You use this key to log in securely to your instance:
- Linux β SSH (
ssh -i mykey.pem ec2-user@IP
) - Windows β RDP with a password derived from the key
Important Tips β
- Download the .pem file when creating a new key pair
- Never lose it β losing it = no entry π±
- Do not share it β itβs your secret magic key π
Quick Security Reminder β
- Security groups = who can come in
- Key pair = how you unlock the door
- Together, they keep your EC2 instance safe from intruders π‘οΈ