Home/Engineer/Cloud/Getting Started with AWS EC2…
CloudBeginnerubuntuawsec2cloud

Getting Started with AWS EC2 Instances

A step-by-step guide to creating an EC2 instance, configuring security groups, connecting via SSH, and completing basic server setup.

Contents
  1. Recommended Settings for Creating an EC2 Instance
  2. Security Group Inbound Rules
  3. SSH Access
  4. Initial Setup After Connecting
  5. AWS CLI Setup
  6. Instance Type Selection Criteria
ItemRecommended value
AMIUbuntu 22.04 LTS
Instance typet3.micro (testing) / t3.small (small-scale)
Storagegp3 20GB+
Key pairCreate a new one and store the .pem file securely

Security Group Inbound Rules

PortSourcePurpose
22My IPSSH
800.0.0.0/0HTTP
4430.0.0.0/0HTTPS

Allow SSH only from your IP — opening it to 0.0.0.0/0 is a security risk.


SSH Access

Bash
chmod 400 my-key.pem
ssh -i my-key.pem ubuntu@<EC2-PUBLIC-IP>

# ~/.ssh/config
Host myserver
    HostName 123.45.67.89
    User ubuntu
    IdentityFile ~/.ssh/my-key.pem
    ServerAliveInterval 60

ssh myserver

Initial Setup After Connecting

Bash
sudo apt update && sudo apt upgrade -y

sudo apt install -y curl wget git vim htop build-essential ufw fail2ban

sudo timedatectl set-timezone Asia/Seoul

# file (t3.micro )
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

sudo ufw allow 22/tcp && sudo ufw allow 80/tcp && sudo ufw allow 443/tcp
sudo ufw enable

AWS CLI Setup

Bash
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip && sudo ./aws/install

aws configure
# Region: ap-northeast-2

aws ec2 describe-instances \
  --query 'Reservations[*].Instances[*].[InstanceId,State.Name,PublicIpAddress]' \
  --output table

Instance Type Selection Criteria

FamilyUse caseExample
t3/t4gGeneral purpose, burstableSmall web servers
m6i/m7iGeneral purpose, consistent performanceAPI servers
c6i/c7iCompute-intensiveRendering, batch jobs
r6i/r7iMemory-intensiveDatabases, caches
#aws#ec2#cloud#ssh#ubuntu
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)AWS documentation ↗Linux man pages ↗

Questions & answers

Ask a question about this guide. We'll review and reply.