Back to Browse

Day 22: Configuring Secure SSH Access to an EC2 Instance

30 views
May 4, 2026
27:13

☁️ Day 22: Configuring Secure SSH Access to an EC2 Instance | 100 Days of Cloud (AWS) Welcome to Day 22 of the 100 Days of Cloud (AWS) series! In this lab, you’ll create an EC2 instance and configure secure, passwordless SSH access using key-based authentication. 📌 Lab Objective: Launch an EC2 instance and enable root login using an SSH key from the aws-client host. 🛠️ Task Requirements: Instance Name: datacenter-ec2 Instance Type: t2.micro Region: us-east-1 Create SSH key: /root/.ssh/id_rsa (on aws-client) Enable passwordless SSH login as root 💻 Step-by-Step Solution: 🔹 1. Check/Create SSH Key (on aws-client) ls /root/.ssh/id_rsa 👉 If not present: ssh-keygen -t rsa -b 2048 -f /root/.ssh/id_rsa -N "" 🔹 2. Launch EC2 Instance aws ec2 run-instances \ --image-id AMI-ID \ --instance-type t2.micro \ --count 1 \ --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=datacenter-ec2}]' 🔹 3. Get Public IP aws ec2 describe-instances \ --filters "Name=tag:Name,Values=datacenter-ec2" \ --query "Reservations[].Instances[].PublicIpAddress" \ --output text 🔹 4. SSH into EC2 (default user) ssh -i /root/.ssh/id_rsa ubuntu@PUBLIC-IP 👉 Use ubuntu if using Ubuntu AMI 🔹 5. Add Public Key to Root User On EC2: sudo mkdir -p /root/.ssh sudo chmod 700 /root/.ssh Copy public key from aws-client: cat /root/.ssh/id_rsa.pub Paste into: sudo vi /root/.ssh/authorized_keys Set permissions: sudo chmod 600 /root/.ssh/authorized_keys 🔹 6. Enable Root SSH Login sudo vi /etc/ssh/sshd_config Update: PermitRootLogin yes PubkeyAuthentication yes Restart SSH: sudo systemctl restart sshd 🔹 7. Test Passwordless SSH From aws-client: ssh root@PUBLIC-IP ✅ Login should work without password 📚 What You’ll Learn: SSH key generation and usage Launching EC2 instances via CLI Configuring authorized_keys Enabling secure root access Passwordless authentication 🌟 Why This Lab Matters: SSH key-based authentication is a core DevOps security practice, used in automation, CI/CD pipelines, and cloud infrastructure management. 🎯 Series: 100 Days of Cloud (AWS) Build real-world cloud skills step by step. 🔔 Follow OtterTech for more hands-on labs and practical tutorials! #AWS #EC2 #SSH #CloudComputing #DevOps #Security #Linux #100DaysOfCloud #OtterTech #Day22

Download

1 formats

Video Formats

360pmp425.7 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Day 22: Configuring Secure SSH Access to an EC2 Instance | NatokHD