Home AWSHow to Launch Your First EC2 Instance on AWS: A Step-by-Step Guide

How to Launch Your First EC2 Instance on AWS: A Step-by-Step Guide

by Knowledge Base Linux
How to Launch Your First EC2 — How to Launch Your First EC2 Instance on AWS: A Step-by-Step Guide

Amazon EC2 (Elastic Compute Cloud) gives you a virtual Linux server in the cloud in under five minutes — no hardware, no data center. If you want to launch EC2 instance resources for the first time, the console wizard walks you through every choice, but the defaults matter: pick the wrong AMI, instance type, or security group rule and you either pay more than expected or lock yourself out. This guide launches a free-tier-eligible Ubuntu server, connects to it over SSH, and installs a web server as proof it works. This article covers How to Launch Your First EC2 in detail.

Configuring settings to launch EC2 instance securely

Prerequisites – How to Launch Your First EC2

  • An AWS account with a valid payment method. New accounts get the AWS Free Tier: 750 hours/month of eligible EC2 instances for 12 months.
  • A terminal with an SSH client — built in on macOS and Linux, or OpenSSH on Windows 10/11. See our guide to SSH into a Linux server for a refresher.
  • About 15 minutes.

One cost warning up front: instances you forget to terminate keep billing. We will show you how to clean up at the end.

Step 1: Open the EC2 Console and Start the Wizard – How to Launch Your First EC2

Sign in to the AWS Management Console, type EC2 in the top search bar, and open the EC2 dashboard. Click the orange Launch instance button. This opens the single-page launch wizard where all the steps below happen.

Tip: choose a Region close to you or your users (top-right corner) before launching — you cannot change an instance’s region later.

Step 2: Name the Instance and Choose an AMI

Under Name and tags, enter something descriptive, e.g. my-first-web-server. Under Application and OS Images (Amazon Machine Image), stay on the Quick Start tab and select Ubuntu Server 22.04 LTS (HVM), SSD Volume Type — it carries the green Free tier eligible badge. An AMI is simply a prebuilt OS template; Ubuntu 22.04 LTS gives you five years of support and huge community documentation. Leave the architecture at 64-bit (x86) for maximum compatibility.

Step 3: Choose the Instance Type

In the Instance type dropdown, select t3.micro (2 vCPU, 1 GB RAM) — currently the free-tier-eligible default. (Older accounts may still see t2.micro; either is fine.) A micro instance is plenty for learning, a small website, or a test Docker host. Resist the urge to pick a larger type “just in case” — that is how surprise bills happen.

Step 4: Create a Key Pair for SSH Access

Under Key pair (login), click Create new key pair:

  1. Key pair name: my-ec2-key.
  2. Key pair type: RSA.
  3. Private key file format: .pem (for OpenSSH on macOS/Linux). Choose .ppk only if you use PuTTY on Windows.
  4. Click Create key pair — the file downloads immediately. You cannot download it again later.

Store it safely and lock down its permissions, or SSH will refuse to use it:

mkdir -p ~/.ssh/aws
mv ~/Downloads/my-ec2-key.pem ~/.ssh/aws/
chmod 400 ~/.ssh/aws/my-ec2-key.pem

If you already have your own key pair, you can instead import your public key — see our guide on generating SSH keys on Linux — but for a first launch, creating the pair in the console is simplest.

Step 5: Configure Network Settings and the Security Group

A security group is EC2’s virtual firewall. Under Network settings:

  • VPC and Subnet: leave the defaults (your default VPC).
  • Auto-assign public IP: Enable — you need a public IP to reach the instance over the internet.
  • Firewall (security groups): choose Create security group.
  • Under Inbound security groups rules, keep the default rule: Type ssh, Protocol TCP, Port 22, Source My IP. This allows SSH only from your current IP address — never open port 22 to 0.0.0.0/0 on a real server.
  • Click Add security group rule and add: Type http, Port 80, Source Anywhere-IPv4 (0.0.0.0/0). This lets the world load the demo web page we will install later.

Step 6: Configure Storage and Launch

Under Configure storage, the default 8 GiB gp3 volume is free-tier eligible (up to 30 GB of EBS is free). Leave it as-is for this exercise. Review the Summary panel on the right — it should show $0.00 estimated cost for free-tier-eligible resources — then click Launch instance. Back on the Instances page, wait until Instance state shows Running and both status checks show 2/2 checks passed (usually 1–3 minutes). Note the Public IPv4 address — you will need it next.

Step 7: Connect to Your Instance Over SSH

When you launch EC2 instance resources with an Ubuntu AMI, the default username is ubuntu (for Amazon Linux it would be ec2-user). Connect from your terminal:

ssh -i ~/.ssh/aws/my-ec2-key.pem ubuntu@<your-public-ip>

Accept the host key fingerprint on first connect. You should land at a shell prompt like ubuntu@ip-172-31-16-42:~$. You now have root-equivalent access via sudo.

Step 8: Install a Web Server as a Smoke Test

Prove the instance works end-to-end by serving a page:

sudo apt update && sudo apt install -y nginx
sudo systemctl enable --now nginx
curl -s -o /dev/null -w "%{http_code}\n" http://localhost

The last command should print 200. Now open http://<your-public-ip> in a browser — you should see the Nginx welcome page. Your EC2 instance is live on the internet.

Step 9: Clean Up When You Are Done

A stopped instance still accrues EBS storage charges; only termination stops billing completely. When finished experimenting: in the EC2 console, select the instance, click Instance state > Terminate instance, and confirm. For deeper EC2 topics — IAM roles, Elastic IPs, snapshots, and CloudWatch alarms — the official Amazon EC2 documentation is the authoritative reference.

Troubleshooting

1. “Permission denied (publickey)” when connecting

This is the most common first-launch error and has three usual causes: (a) wrong username — use ubuntu for Ubuntu AMIs, ec2-user for Amazon Linux, never root; (b) wrong key file — the -i path must point to the .pem downloaded at launch; (c) key permissions too open — run chmod 400 on the key file, SSH rejects keys readable by others.

2. “Connection timed out” on SSH

A timeout (as opposed to permission denied) means packets are being dropped — almost always the security group. In the console, check the instance’s security group inbound rules: there must be a rule for TCP port 22 with source My IP (your current public IP — if your ISP changed your IP since launch, the rule no longer matches). Also confirm Auto-assign public IP was enabled; without a public IP, SSH from the internet cannot reach the instance.

3. Instance stuck in “pending” or failing status checks

If the instance stays in pending for more than a few minutes, the Availability Zone may be constrained — stop it and start it again (it may land on different hardware). If status checks fail after boot (1/2 checks passed), the OS itself is unhealthy: check the system log via Actions > Monitor and troubleshoot > Get system log for kernel errors, and verify you did not exhaust the 8 GB disk during package installs (df -h /).

4. Unexpected charges on the bill

Open Billing > Bills and expand the EC2 section. Typical culprits: an instance left running (not just stopped) past the 750 free-tier hours, an Elastic IP allocated but not attached to a running instance (charged hourly), or EBS snapshots accumulating. Terminate test instances and release unattached Elastic IPs when done.

Conclusion

You now know how to launch EC2 instance resources the right way: pick a free-tier AMI and instance type, create a key pair, lock SSH down to your IP with a security group, connect over SSH, and clean up afterwards. These same steps scale directly to production — the only things that change are bigger instance types, stricter security groups, IAM roles instead of long-lived credentials, and automation with the AWS CLI or Terraform. Your first cloud server is running; what you host on it is up to you.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.