Day-18: EC2 Security (Key Pairs, Security Groups & Elastic IPs)


☁️ Why EC2 Security Matters

When you launch an EC2 instance, it’s publicly accessible over the internet if not properly configured.

AWS provides tools like Key PairsSecurity Groups, and Elastic IPs to manage access and protect your instances.


🔹 1️⃣ Key Pairs (SSH Authentication)

Key Pairs are used to securely connect (SSH) to your EC2 instance.

They consist of two parts:

🧠 Purpose:

Instead of using a password, AWS uses asymmetric encryption (public/private key model) for login security.


🧩 Creating a Key Pair

Option 1: AWS Console

Option 2: AWS CLI

aws ec2 create-key-pair --key-name myKeyPair --query 'KeyMaterial' --output text > myKeyPair.pem