Topic lessonTopic: EC2: launch and operation
Launch your first EC2 instance: a beginner’s guide to SSH and cleanup
A first EC2 exercise includes launching one instance, checking the connection and cleaning up afterward. Follow a defined route: an EBS-backed Amazon Linux 2023 instance, reached over public IPv4 from your own SSH client. This page does not connect to AWS; it explains the decisions, costs and checks for an authorized real-world exercise.
Prepare a launch plan and distinguish EC2 state, SSH connection requirements and resources that may remain after termination.
Understand EC2, AMIs, EBS, VPCs and security groups. A real exercise requires an approved test account with launch and termination permissions, your own SSH client and secure key storage. Reading requires no AWS account.
Define this exercise before opening the launch wizard
- Prepare → Launch oneLaunch only after checking prerequisites and costs.
- Launch one → Verify accessVerify launch and connection as separate outcomes.
- Verify access → Finish and inspectDecide what to retain, then clean up.
- Prepare
- Review permissions, costs, networking and cleanup.
- Launch one
- Choose an AMI, type, key, SG and EBS.
- Verify access
- Check instance status, SSH access and the OS.
- Finish and inspect
- Reconcile deleted and retained resources.
The scope is one x86_64, EBS-backed Amazon Linux 2023 On-Demand instance. The exercise stops at inspecting the OS. It does not publish a website or create extra data volumes, an Elastic IP, a NAT gateway or an Auto Scaling group. A production workload needs its own maintenance, security and recovery design.
Before launch: check six prerequisites
| Check | Requirement for this exercise | If it is unclear |
|---|---|---|
| Permissions and target | An approved test account/Region and launch/termination permissions | Ask the owner; do not substitute root-user access |
| Cost and end condition | One-instance costs, EBS/IPv4 and an end time | Pause launch and review cost and cleanup |
| AMI and instance type | Amazon-provided AL2023, x86_64 compatibility and a suitable type | Verify the publisher and architecture |
| VPC and subnet | An approved VPC, a subnet route to an internet gateway and public IPv4 | Ask the network owner; do not change shared routes |
| SSH and key | Your SSH client and a private key readable only by you | Prepare secure storage and file permissions |
| Traffic controls | TCP 22 from your current source, plus relevant NACL/client controls | Identify the source; do not open access to everyone |
A public subnet alone does not establish connectivity. This IPv4 route requires suitable routing to an attached internet gateway and a public IPv4 address on the instance. Review the SG (security group) for instance-side traffic permissions and the NACL (network ACL) for subnet-boundary controls, plus client restrictions. Do not assume default VPC resources exist or that wizard defaults match your plan.
Launch: review the settings and create one instance
- In the EC2 console, verify the Region and open Launch instance. Give the exercise an identifiable Name tag.
- Choose an Amazon-provided x86_64 Amazon Linux 2023 AMI. Check the publisher rather than relying on a familiar-looking name.
- Choose a compatible instance type after reviewing workload and pricing conditions. Set the instance count to one.
- Select your login key pair. For a new pair, securely store the downloaded private key and do not share it.
- Edit Network settings and select the reviewed VPC, subnet and public IPv4 setting. Use an exercise-specific SG allowing SSH/TCP 22 only from your current public IPv4. Do not add HTTP/HTTPS.
- Review the EBS root volume, at least as large as the AMI requires. Check type, size, encryption, termination deletion and costs. Do not add data volumes.
- Review the Region, AMI, type, one-instance count, key, networking and EBS in the summary. Launch only when the plan matches, then record the instance ID.
“My IP” identifies your current internet-facing source. /32 restricts IPv4 to one address; a VPN or network change can change that source. A newly created private key cannot later be downloaded again from AWS. Never paste keys or credentials into this site’s search, contact form or other inputs.
Connect: check running state, SSH and the OS separately
- EC2 state → SSH sessionCheck status before connecting; running alone does not prove SSH access.
- SSH session → OS inspectionAfter login, inspect the user and OS. Application health is a separate check.
- EC2 state
- Verify the ID, running state and status checks.
- SSH session
- Match destination, route, TCP 22, key and user.
- OS inspection
- Inspect user and OS; this is not a website test.
- Check the target instance is running and has passed status checks. Verify its current public IPv4, AMI username and matching key. The default AL2023 username is ec2-user.
- Restrict the private key to your own user. macOS/Linux permissions and Windows file security are configured differently; use the appropriate method.
- Start SSH on your own computer. Replace the key path and destination below with values for your authorized exercise instance.
- At the initial host-key prompt, compare the fingerprint with the instance’s system-log information. Stop on a mismatch; do not disable verification to continue.
- After login, use whoami and /etc/os-release to inspect the user and OS. Do not install packages or publish a service; end the session with exit.
| Local OS | Setting to check |
|---|---|
| macOS / Linux | Verify the saved key path and use chmod 400 so only its owner can read it. Do not share the file |
| Windows | In the key file’s Properties → Security → Advanced, disable inheritance and remove access for other users. Verify your own read access |
ssh -i ./lesson-key.pem ec2-user@PUBLIC_IPV4whoami
cat /etc/os-release
exitChoose an option to see the result and explanation.
Worked example: investigate the layer that failed
| Observation | First checks | Avoid |
|---|---|---|
| Connection timeout | Current destination, public IPv4, routes, SG source, NACL and client controls | Regenerating keys first or opening SSH to everyone |
| Permission denied (publickey) | AMI username, selected key, private-key path and permissions | Entering the AWS console password into SSH |
| Host-key mismatch | Wrong/reassigned destination and the trusted fingerprint | Disabling StrictHostKeyChecking |
| SSH works but no web page appears | This exercise has not started a web server | Reporting website health from an SSH connection |
Choose an option to see the result and explanation.
Finish: decide what to retain before termination
Stop preserves an instance for a later start; terminate permanently deletes it. For a completed disposable exercise, review required data before deciding to terminate. Stopping can leave EBS charges; closing SSH leaves the instance itself running.
- Match the account, Region and instance ID. Do not select another user’s instance or shared resources.
- Review required data and how it can be restored. Check DeleteOnTermination for each EBS volume and decide what to retain before deletion.
- Use Instance state → Terminate (delete) instance, review the target and consequences, and perform normal termination. This guide does not skip OS shutdown or use force termination.
- Verify the terminated state. A temporarily visible console entry alone does not mean termination failed.
- Reconcile the launch record with remaining EBS volumes, snapshots, IPs and related resources. Keep required/shared resources; remove only unneeded exercise resources through authorized procedures.
Completion: gather three pieces of evidence
| Stage | Evidence to establish |
|---|---|
| Launch | The ID and configuration match the plan, and status checks were inspected |
| Connection | SSH reached the intended instance and its user/OS were inspected; no application-health claim |
| Cleanup | The instance is terminated, retained/unneeded resources were reconciled, and the cost-review scope was recorded |
Choose an option to see the result and explanation.
Check, then explain in your own words
- State the exercise’s OS, connection method, cost conditions and end condition.
- Verify running state, SSH access and OS identity separately.
- Reconcile data and remaining resources against the launch record.
Check your understanding: Launch succeeded but SSH does not. What should you separate first?
Separate instance state, network paths/controls and SSH key/user authentication.
A successful launch does not prove connectivity. Establish the current destination, source and method, investigate the relevant layer, and avoid widening access as a substitute for diagnosis.
Sources and conditions checked
The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.
Scope and conditionsLaunch workflow and review of Region, AMI, instance type, key pair, network and storage. Default values do not establish suitability.
Used in this lessonLaunch: review the settings and create one instance
Scope and conditionsParameter meanings including architecture compatibility, source-specific SSH rules, storage and launch count. Tutorial choices are limited to a disposable Linux exercise.
Used in this lessonLaunch: review the settings and create one instance
Scope and conditionsKey-pair creation/download and the Linux test-instance workflow. This site does not adopt every default or promise Free Tier eligibility.
Used in this lessonLaunch: review the settings and create one instance
- General connection prerequisitesChecked:
Scope and conditionsInstance identity, AMI username, OS-specific private-key file protection and host-fingerprint verification. No keys or instance data collected.
Used in this lessonLaunch: review the settings and create one instance Connect: check running state, SSH and the OS separately
Scope and conditionsDirect SSH from the operator computer; status checks, key/user/destination and traffic from the actual source. Not browser Instance Connect.
Used in this lessonConnect: check running state, SSH and the OS separately
Scope and conditionsDistinguishes browser service-source prefix lists, required IAM/software/network prerequisites, and direct-client source rules. No EIC endpoint created.
Used in this lessonBefore launch: check six prerequisites
Scope and conditionsInternet-gateway attachment/routing and public IPv4 for the selected direct-internet IPv4 method. Not a complete end-to-end connection guarantee.
Used in this lessonBefore launch: check six prerequisites
- Terminate Amazon EC2 instancesChecked:
Scope and conditionsNormal console termination, irreversibility and temporary visibility of terminated entries. This guide does not skip OS shutdown or force termination.
Used in this lessonFinish: decide what to retain before termination
- Amazon EC2 On-Demand pricingChecked:
Scope and conditionsCompute assumptions, OS-specific billing granularity, data transfer and additional resource charges; no unit rates embedded.
Used in this lessonDefine this exercise before opening the launch wizard
- Amazon EBS pricingChecked:
Scope and conditionsProvisioned capacity, additional performance and snapshots; no unit rate or price quote is embedded.
Used in this lessonDefine this exercise before opening the launch wizard Finish: decide what to retain before termination Completion: gather three pieces of evidence
- Amazon VPC pricingChecked:
Scope and conditionsPublic IPv4 and NAT gateway pricing dimensions, including retained/idle addresses; no unit-rate quote.
Used in this lessonDefine this exercise before opening the launch wizard Finish: decide what to retain before termination
- Managing costs with AWS BudgetsChecked:
Scope and conditionsNotification and billing delays; alert is not a hard cap
Used in this lessonDefine this exercise before opening the launch wizard
- Security group rulesChecked:
Scope and conditionsAllow-rule fields, associated-rule aggregation and effects of changes; not universal application reachability.
Used in this lessonBefore launch: check six prerequisites
- Network ACL rulesChecked:
Scope and conditionsDirection, protocol, port, peer CIDR and first matching rule in ascending order.
Used in this lessonBefore launch: check six prerequisites
- EC2 instance state changesChecked:
Scope and conditionsEBS-backed stop/start, hibernation and termination differ
Used in this lessonConnect: check running state, SSH and the OS separately Finish: decide what to retain before termination
Scope and conditionsData loss and persistence; DeleteOnTermination is evaluated for each EBS volume, not assumed from instance state.
Used in this lessonFinish: decide what to retain before termination Completion: gather three pieces of evidence
- Understanding unexpected chargesChecked:
Scope and conditionsResources in all Regions; deletion and data retention need review
Used in this lessonFinish: decide what to retain before termination