INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

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.

What you will learn

Prepare a launch plan and distinguish EC2 state, SSH connection requirements and resources that may remain after termination.

Prerequisite

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

Exercise sequence: decisions before launch, verification and cleanup afterward
Exercise sequence: decisions before launch, verification and cleanup afterward1: Prepare — Launch only after checking prerequisites and costs. — Launch one. 2: Launch one — Verify launch and connection as separate outcomes. — Verify access. 3: Verify access — Decide what to retain, then clean up. — Finish and inspect123PrepareLaunch oneVerify accessFinish and inspectExercise sequence: decisions before launch, verification and cleanup afterward1: Prepare — Launch only after checking prerequisites and costs. — Launch one. 2: Launch one — Verify launch and connection as separate outcomes. — Verify access. 3: Verify access — Decide what to retain, then clean up. — Finish and inspect123PrepareLaunch oneVerify accessFinish andinspect
  1. Prepare → Launch oneLaunch only after checking prerequisites and costs.
  2. Launch one → Verify accessVerify launch and connection as separate outcomes.
  3. 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

Resolve missing prerequisites before creating resources
CheckRequirement for this exerciseIf it is unclear
Permissions and targetAn approved test account/Region and launch/termination permissionsAsk the owner; do not substitute root-user access
Cost and end conditionOne-instance costs, EBS/IPv4 and an end timePause launch and review cost and cleanup
AMI and instance typeAmazon-provided AL2023, x86_64 compatibility and a suitable typeVerify the publisher and architecture
VPC and subnetAn approved VPC, a subnet route to an internet gateway and public IPv4Ask the network owner; do not change shared routes
SSH and keyYour SSH client and a private key readable only by youPrepare secure storage and file permissions
Traffic controlsTCP 22 from your current source, plus relevant NACL/client controlsIdentify 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

  1. In the EC2 console, verify the Region and open Launch instance. Give the exercise an identifiable Name tag.
  2. Choose an Amazon-provided x86_64 Amazon Linux 2023 AMI. Check the publisher rather than relying on a familiar-looking name.
  3. Choose a compatible instance type after reviewing workload and pricing conditions. Set the instance count to one.
  4. Select your login key pair. For a new pair, securely store the downloaded private key and do not share it.
  5. 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.
  6. 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.
  7. 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

Three connection checks; arrows show verification order
Three connection checks; arrows show verification order1: EC2 state — Check status before connecting; running alone does not prove SSH access. — SSH session. 2: SSH session — After login, inspect the user and OS. Application health is a separate check. — OS inspection12EC2 stateSSH sessionOS inspectionThree connection checks; arrows show verification order1: EC2 state — Check status before connecting; running alone does not prove SSH access. — SSH session. 2: SSH session — After login, inspect the user and OS. Application health is a separate check. — OS inspection12EC2 stateSSH sessionOS inspection
  1. EC2 state → SSH sessionCheck status before connecting; running alone does not prove SSH access.
  2. 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.
  1. 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.
  2. Restrict the private key to your own user. macOS/Linux permissions and Windows file security are configured differently; use the appropriate method.
  3. Start SSH on your own computer. Replace the key path and destination below with values for your authorized exercise instance.
  4. 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.
  5. 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.
Private-key file access: use the method for your local OS
Local OSSetting to check
macOS / LinuxVerify the saved key path and use chmod 400 so only its owner can read it. Do not share the file
WindowsIn the key file’s Properties → Security → Advanced, disable inheritance and remove access for other users. Verify your own read access
Command format on your own computer; replace PUBLIC_IPV4 for your instance
ssh -i ./lesson-key.pem ec2-user@PUBLIC_IPV4
Read-only checks after login; exit closes the SSH session
whoami
cat /etc/os-release
exit

Choose an option to see the result and explanation.

You closed SSH with exit. Has the EC2 instance stopped?
Read the answer and reason

Answer: No: only the session ended; check instance state · Exit ends the remote shell session. Stopping or terminating EC2 is a separate action; check the console and complete cleanup.

Worked example: investigate the layer that failed

Use the symptom to choose checks, not to invent a diagnosis
ObservationFirst checksAvoid
Connection timeoutCurrent destination, public IPv4, routes, SG source, NACL and client controlsRegenerating keys first or opening SSH to everyone
Permission denied (publickey)AMI username, selected key, private-key path and permissionsEntering the AWS console password into SSH
Host-key mismatchWrong/reassigned destination and the trusted fingerprintDisabling StrictHostKeyChecking
SSH works but no web page appearsThis exercise has not started a web serverReporting website health from an SSH connection

Choose an option to see the result and explanation.

SSH times out after switching to a VPN. The SG still permits the old public IPv4 /32. What should you check first?
Read the answer and reason

Answer: Compare the current source with the existing rule · First establish whether the source changed. If authorized, update the rule narrowly for the new source. This observation alone does not prove there are no other causes.

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.

  1. Match the account, Region and instance ID. Do not select another user’s instance or shared resources.
  2. Review required data and how it can be restored. Check DeleteOnTermination for each EBS volume and decide what to retain before deletion.
  3. 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.
  4. Verify the terminated state. A temporarily visible console entry alone does not mean termination failed.
  5. 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

Confirm the outcome with observed facts
StageEvidence to establish
LaunchThe ID and configuration match the plan, and status checks were inspected
ConnectionSSH reached the intended instance and its user/OS were inspected; no application-health claim
CleanupThe instance is terminated, retained/unneeded resources were reconciled, and the cost-review scope was recorded

Choose an option to see the result and explanation.

EC2 is terminated, but a retained EBS volume remains. Can you report “everything deleted and zero cost”?
Read the answer and reason

Answer: No: review retention and remaining resource costs · Terminated describes that instance. Review why the volume remains and what it costs, then continue authorized cleanup if appropriate.

Check, then explain in your own words

  1. State the exercise’s OS, connection method, cost conditions and end condition.
  2. Verify running state, SSH access and OS identity separately.
  3. 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.