DEV Community

LaTerral Williams
LaTerral Williams

Posted on • Edited on

🚀How to Set Up a RHEL 9 VM in AWS EC2 and Connect with PuTTY (Beginner-Friendly Guide)

If you’re preparing for the RHCSA exam or just getting started with Linux in the cloud, AWS EC2 is a great place to spin up a Red Hat Enterprise Linux 9 (RHEL 9) VM for hands-on practice.

In this guide, we’ll walk through:

  • Creating a RHEL 9 instance in AWS EC2
  • Choosing the right instance type (and free tier tips)
  • Converting your AWS key to a PuTTY-compatible format
  • Connecting with PuTTY
  • Setting up security groups for SSH access
  • Troubleshooting common connection issues

📑 Table of Contents


1️⃣ Launch a RHEL 9 Instance

  1. Log in to the AWS Management Console and go to EC2Launch Instances.
  2. Name your instance (e.g., rhel9-lab).
  3. Under Amazon Machine Image (AMI), search for:

Red Hat Enterprise Linux 9

  1. Select the latest version.
  2. Choose your instance type (see below).

2️⃣ Choose the Right Instance Type

For free tier eligibility:

  • t2.micro or t3.micro are free tier–eligible.
  • Important: RHEL still has a license cost, even on free tier.
  • If you want completely free practice but still RHCSA-compatible, choose Rocky Linux 9 or AlmaLinux 9, they’re free and similar to RHEL.

3️⃣ Configure Security Group for SSH

Security groups control inbound/outbound traffic to your VM.

  • Add an Inbound Rule:
  • Type: SSH
  • Port Range: 22
  • Source: My IP (most secure) or Anywhere (0.0.0.0/0) if you need flexibility during testing.

💡 For my RHCSA lab, I had to temporarily set Anywhere to connect from multiple networks. Remember to restrict this in a real-world environment for security best practice.


4️⃣ Download and Convert the AWS Key

When launching your instance, AWS will prompt you to create or use an existing Key Pair.

  1. Download the .pem file — keep it safe!
  2. Install PuTTYgen (comes with PuTTY).
  3. Open PuTTYgen → Load your .pem file (set file filter to All Files).
  4. Click Save Private Key → Save as .ppk.

📝 Why convert? PuTTY only works with .ppk (private key) format. The public key is already on your AWS instance.


5️⃣ Connect with PuTTY

  1. Open PuTTY.
  2. In Host Name, enter:
ec2-user@<Your Public IPv4 DNS or IP>
Enter fullscreen mode Exit fullscreen mode
  1. Go to Connection → SSH → Auth → Credentials → Browse and select your .ppk file.
  2. Click Open → Accept the SSH security alert.

You should now be connected as ec2-user.


6️⃣ Gain Root Access

AWS disables direct root SSH login by default for security.

To run commands as root use:

sudo
Enter fullscreen mode Exit fullscreen mode

You now have a root shell for RHCSA practice.


7️⃣ Troubleshooting PuTTY SSH Issues

  • Error: Connection timed out

    → Check security group rules for inbound SSH on port 22.

  • Error: Server refused our key

    → Ensure you loaded the correct .ppk file in PuTTY.

  • Only works from one location

    → Your security group might be set to “My IP.” Change to “Anywhere” during testing.


💰 Cost-Saving Tip: Stop Your Instance When Not in Use

AWS charges for your EC2 instance while it’s running — even if you’re not connected.

If you’re using your VM for RHCSA practice or occasional testing, stop the instance when you’re done:

  1. In the AWS EC2 Console, select your instance.
  2. Click Instance State → Stop Instance.
  3. Your instance will shut down, but all data on the attached EBS volume will be preserved.

🔹 You can start it again anytime, but remember: if you have a public IP, it may change unless you use an Elastic IP.

This simple step can save you money while keeping your lab ready for next time.


Final Tip: For RHCSA exam prep, using AWS with RHEL 9 is convenient, but if you want to avoid costs while learning Linux, Rocky Linux 9 or AlmaLinux 9 on t2.micro is free tier–eligible.

Top comments (0)