AWS

How to Deploy EC2 Ubuntu 22.04 LTS Instance on AWS

This guide walks you through how to deploy an EC2 Ubuntu 22.04 LTS instance on AWS using the Management Console, then connect to it…

Share:

How to Deploy EC2 Ubuntu 22.04 LTS Instance on AWS

5 min read
1.8K views

This guide walks you through how to deploy an EC2 Ubuntu 22.04 LTS instance on AWS using the Management Console, then connect to it over SSH. The SSH commands shown here are run from WSL2 Ubuntu on Windows, but they work the same on any Linux or macOS terminal.

You would need this any time you want a Linux server in the cloud — hosting a web app, running a database, setting up a staging environment, or just having a sandbox to test things on. EC2 is one of the first services most people use on AWS, Ubuntu 22.04 LTS gets standard security updates until April 2027. For a brand-new server, pick Ubuntu 24.04 LTS instead (supported until 2029). Every step in this guide is identical; only the AMI name changes.

Advertisement

Prerequisites

  • An AWS account
  • IAM permissions to launch EC2 instances
  • A terminal with SSH — on Windows, use WSL 2 with Ubuntu

Launch an EC2 Ubuntu 22.04 Instance

Step 1: Open the EC2 Dashboard

Log in to the AWS Console. Type EC2 in the top search bar and click the service. Check the Region in the top-right corner — pick one close to your users.

Step 2: Start the Launch Wizard

Click Launch instances. Enter a name for the instance under Name and tags — something like web-server or dev-sandbox.

How to Deploy EC2 Ubuntu 22.04 LTS Instance on AWS

Step 3: Select the AMI

Under Application and OS Images, search for Ubuntu and select Ubuntu Server 22.04 LTS (HVM), SSD Volume Type (or Ubuntu Server 24.04 LTS for a longer support window). Keep the architecture on 64-bit (x86).

Advertisement
How to Deploy EC2 Ubuntu 22.04 LTS Instance on AWS

Step 4: Choose an Instance Type

The instance type sets the CPU, memory, and network capacity. For testing or light workloads, t3.micro works well. What counts as Free Tier depends on when your AWS account was created:

  • Created on or after 15 July 2025 — you get the credit-based free plan (up to $200 in credits, for 6 months or until the credits run out). Eligible types include t3.micro, t3.small, t4g.micro, and t4g.small.
  • Created before 15 July 2025 — the legacy Free Tier covers 750 hours/month of t2.micro (or t3.micro in Regions without t2) for 12 months.

The console marks eligible types with a Free tier eligible label, so check that before you launch.

TypevCPUsRAMPrice (us-east-1)Free Tier
t2.micro11 GB$0.0116/hrOlder accounts only
t3.micro21 GB$0.0104/hrYes
t3.small22 GB$0.0208/hrNew accounts (since July 2025)

Running a web server and database together? Pick at least t3.small. You can resize later by stopping the instance and changing the type.

Step 5: Create or Select a Key Pair

Under Key pair (login), pick an existing key or click Create new key pair. Choose ED25519 (shorter, modern keys, supported for Linux instances) or RSA, and .pem format. The private key file downloads once — AWS does not store it, so keep it safe.

After downloading, move it into your Linux home and set the right permissions. On WSL, the browser saves to the Windows Downloads folder, which WSL sees under /mnt/c:

mkdir -p ~/.ssh
mv /mnt/c/Users/your-windows-user/Downloads/my-key.pem ~/.ssh/
chmod 400 ~/.ssh/my-key.pem

On native Linux or macOS, the file is in ~/Downloads/my-key.pem instead. Keep the key inside the Linux filesystem: files under /mnt/c can’t be given strict permissions, so SSH would refuse them. Confirm the permissions show -r--------:

ls -l ~/.ssh/my-key.pem

chmod 400 makes the file read-only for the owner. SSH will reject the key if permissions are too open.

Step 6: Configure Network and Security Group

The default VPC and subnet work for most setups. Make sure Auto-assign public IP is enabled so you can reach the instance from the internet. For custom VPC planning, see How to Design IP Addressing for Amazon VPC and Subnets.

Create a security group with these inbound rules:

TypePortSource
SSH22My IP
HTTP800.0.0.0/0
HTTPS4430.0.0.0/0

Always set SSH to My IP. Leaving port 22 open to 0.0.0.0/0 means bots will start hitting it almost immediately. You can skip the HTTP/HTTPS rules if you only need terminal access.

Step 7: Set Storage Size

The default root volume is a small General Purpose SSD (typically 8 GB). For a test box, that is enough. If you plan to store data, increase to 20-30 GB. Check the volume type too: if it shows gp2, switch it to gp3 — it is cheaper per GB and gives a baseline of 3,000 IOPS regardless of size.

Step 8: Review and Launch

Check the Summary panel on the right. Confirm your AMI, instance type, key pair, security group, and storage look correct. Click Launch instance.

How to Deploy EC2 Ubuntu 22.04 LTS Instance on AWS

Click the instance ID on the success page to go to the Instances dashboard.

Connect to the Instance via SSH

Wait until Instance state shows Running and Status check shows 2/2 checks passed. Copy the Public IPv4 address from the instance details.

ssh -i ~/.ssh/my-key.pem ubuntu@203.0.113.10
  • -i ~/.ssh/my-key.pem — path to your private key
  • ubuntu — default username for Ubuntu AMIs (not root or ec2-user)
  • 203.0.113.10 — replace with your instance’s public IP

Type yes when prompted to accept the host fingerprint. You should see a prompt like ubuntu@ip-172-31-xx-xx:~$ — you are in.

First thing to do is update packages:

sudo apt update && sudo apt upgrade -y

Prefer not to open port 22 at all? You can connect from the console with EC2 Instance Connect, or use AWS SSM Session Manager, which needs no inbound rules and no key file. Both are safer defaults for servers that don’t need direct SSH.

To avoid typing the -i flag every time, you can configure SSH keys permanently. See How to Setup Passwordless SSH Login on EC2 Ubuntu 22.04.

Stop vs Terminate

Stop shuts down the server but keeps the disk. You still pay for EBS storage. Use this when you want to pause and come back later.

Terminate deletes the instance and its root volume permanently. Use this when you are done with the server.

How to Deploy EC2 Ubuntu 22.04 LTS Instance on AWS

To do either: go to the EC2 dashboard, select the instance, click Instance state, and pick Stop or Terminate.

Troubleshooting

Connection Timed Out

  • Your security group may not allow SSH from your current IP — your IP might have changed since you set the rule
  • Make sure you are using the public IP, not the private one
  • Confirm the instance is in the Running state

Permission Denied (publickey)

  • Run chmod 400 on your key file — SSH rejects keys with open permissions
  • Check you are using ubuntu as the username, not root
  • Make sure the key file matches the key pair you selected during launch

Conclusion

You now have a running Ubuntu 22.04 LTS EC2 instance that you can SSH into. This is the foundation for most AWS server setups — web hosting, APIs, background workers, or staging environments.

From here, you might want to install Apache to host a website or add swap space if your instance is running low on memory. If other people need access, create separate user accounts instead of sharing the ubuntu key. Want a full site? Follow How to Install WordPress on EC2 Ubuntu 22.04.

Recommended for Linux builders

Contabo VPS hosting for Linux projects

Run Linux servers, automation tools, and self-hosted apps on a Contabo VPS with generous resources and predictable pricing.

Our customers sayExcellent4.6 out of 5 based on 11,008 reviews Trustpilot

Some links are affiliate links. This may earn LinuxBeast a commission at no extra cost to you.

Privacy settings

Choose which privacy controls to open.

Opening these controls does not change your saved choices.