Skip to main content
This lesson shows how to launch a basic Amazon Linux EC2 instance, create and use a key pair to SSH into the instance, inspect instance details, and stop or terminate the instance to avoid charges. Follow the step-by-step instructions and refer to the console screenshots for context. We begin by opening the Amazon Elastic Compute Cloud (EC2) service and navigating to Instances. You can also use the Launch instances shortcut.
A screenshot of the Amazon Web Services EC2 console showing the EC2 dashboard, resources, and account attributes for the US East (N. Virginia) region. The left navigation menu, launch instance button, and service health/zones panels are visible.

Launching an instance — step by step

  1. Click Launch instances.
  2. Give the instance a Name (for example, ec2-demo-instance).
  3. Choose an AMI (Amazon Machine Image). The AMI is the image blueprint that determines the operating system and any preinstalled packages.
The console displays Quick Start AMIs (Amazon Linux, Ubuntu, etc.), your own AMIs under “My AMIs”, and Marketplace AMIs with vendor-provided images.
A screenshot of the AWS EC2 console "Choose an Amazon Machine Image (AMI)" page. It shows search results for Ubuntu AMIs (e.g., Ubuntu 20.04 and 18.04) with Select buttons and filtering options.
For this demo we’ll select the Amazon Linux 2023 AMI. Note that each AMI has a specific AMI ID and AMI IDs are region-specific — the ID you see depends on the region you’re viewing.
AMI IDs are region-specific. An AMI ID in one region will be different in another region even if it’s the same AMI name.
  1. Choose an instance type. For simple testing, t2.micro is commonly Free Tier–eligible (subject to account and regional eligibility).
  2. Key pair: select an existing key pair or create a new one. A key pair (.pem) is typically required for SSH access; AWS also offers Instance Connect and other access workflows.
When creating a new key pair:
  • Provide a name (e.g., ec2-demo).
  • Choose RSA and the .pem file format.
  • Create and download the .pem file.
A screenshot of the AWS EC2 web console showing the "Create key pair" dialog with a key pair name "ec2-demo", RSA selected and .pem file format chosen. The "Create key pair" button is highlighted at the bottom.
Store your .pem file securely and restrict its permissions (see the SSH section below). If you lose it, you cannot use it to SSH into the instance unless another access method has been configured.
  1. Network settings: choose a VPC and subnet (the default VPC/subnet is fine for this demo). Enable a public IP if you need SSH from the internet.
  2. Security group: use an existing group or create a new one. The console often adds an SSH (port 22) inbound rule by default — for production, restrict the Source CIDR rather than using 0.0.0.0/0.
  3. Storage: the default root EBS volume is typically 8 GiB; add volumes if required.
A screenshot of the AWS EC2 "Launch Instances" console showing inbound security group rules (SSH open to 0.0.0.0/0), storage configuration, and the summary panel with instance details and a "Launch instance" button.
  1. Advanced details (optional): Spot instances, IAM instance profiles, shutdown behavior, and user data are available here. For this demo, leave defaults.
  2. Click Launch instance.

What to look for on the Instances page

After launch, open Instances to inspect the new instance. Important fields and where to find them:
  • Instance ID and Name
  • State (running, stopped, terminated)
  • Instance type and Availability Zone
  • Public IP and Public DNS (if enabled) — usable for SSH
  • Security groups and Key name
  • Monitoring, tags, and EBS volumes (Storage tab)
A screenshot of the AWS EC2 console showing a running EC2 instance named "ec2-demo-instance" (t2.micro) in the us-east-1 region. The instance details show security group rules including an inbound TCP rule allowing port 22 from 0.0.0.0/0.
The Storage tab shows the root EBS volume and device mapping:
A screenshot of the AWS EC2 console showing one running instance (ec2-demo-instance, i-0301...) with 2/2 status checks passed. The Storage tab is open, showing the root device /dev/xvda and an attached 8 GiB EBS volume.

Connecting via SSH

Use the Connect dialog on the instance page for guided instructions; it shows allowed connection methods and the default username for the chosen AMI.
A screenshot of the AWS EC2 console showing the "Connect to instance" page. It displays connection options (EC2 Instance Connect selected), the instance ID, public IP address, username set to "ec2-user," and a Connect button.
On your local machine:
  1. Save the downloaded .pem (for example, ec2-demo.pem) to a secure directory.
  2. Restrict its permissions so SSH accepts it:
  1. SSH to the instance using the correct username and the instance public DNS or IP. Example for Amazon Linux:
Example session (abbreviated):
If you’re unsure of the default username for an AMI, consult the AMI documentation or the Connect instructions in the EC2 console. Default SSH usernames (quick reference) Useful AWS documentation: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

Instance lifecycle: stop, start, terminate

From the EC2 console, select the instance and use Instance State to control its lifecycle. Summary table: Notes:
  • Instance store (ephemeral) volumes are lost when the instance stops or terminates.
  • EBS-backed instances preserve attached EBS volumes while stopped (and storage costs continue).
  • Avoid leaving test instances running to prevent unintended charges. For this demo, terminate the instance when finished.

Summary

  • Launch: Select AMI, choose instance type, configure key pair, network, security group, and storage.
  • Connect: Secure your .pem file (chmod 400), then SSH with the appropriate username.
  • Manage: Use Instance State to stop, start, or terminate; check the Storage tab for EBS details.
Links and references That concludes this lesson on launching, connecting to, and managing a basic EC2 instance.

Watch Video

Practice Lab