4. Amazon EC2: Launch and Connect to Your Linux Server
4.3 Launching an Instance Step by Step
Chala, aata actual launch karuya. AWS Management Console madhe login kara aani varti ujvikade region Asia Pacific (Mumbai) ap-south-1 nivda.
Step 1 — Open EC2. Search "EC2" in the top search bar → EC2 Dashboard → Launch instance.
Step 2 — Name and tags. Name: web-server-1. (This creates a tag Name=web-server-1.)
Step 3 — Choose an AMI. Under Application and OS Images choose one of:
- Amazon Linux 2023 AMI (default, free-tier eligible) — user
ec2-user - Ubuntu Server 24.04 LTS (or 22.04 LTS) — user
ubuntu - CentOS Stream 9 — search Browse more AMIs → AWS Marketplace / Community AMIs for the official "CentOS Stream 9" image — user
ec2-user(older CentOS images usedcentos)
Keep architecture 64-bit (x86) unless you chose a Graviton type.
Step 4 — Instance type. Choose a free-tier eligible type such as t3.micro or t2.micro (label shown in the list).
Step 5 — Key pair (login). Click Create new key pair → name mykey → type RSA or ED25519 → format .pem (for OpenSSH on Linux/Mac/Windows 10+) or .ppk (for PuTTY) → Create. The file downloads only once — keep it safe.
Step 6 — Network settings. Click Edit:
- VPC: default VPC; Subnet: No preference (or pick an AZ)
- Auto-assign public IP: Enable
- Firewall (security groups): Create security group, name
web-sg, with inbound rules:
| Type | Protocol | Port | Source | Why |
|---|---|---|---|---|
| SSH | TCP | 22 | My IP (e.g. 198.51.100.7/32) |
Only you can log in |
| HTTP | TCP | 80 | Anywhere-IPv4 0.0.0.0/0 |
Website |
| HTTPS | TCP | 443 | Anywhere-IPv4 0.0.0.0/0 |
Secure website |
Step 7 — Configure storage. Default root volume 8 GiB gp3 (Ubuntu defaults to 8 GiB; you can set up to 30 GiB within typical free-tier storage limits).
Step 8 — Advanced details (optional). Paste a User data script to auto-install a web server at first boot, for example on Amazon Linux 2023:
#!/bin/bash
yum install -y nginx
echo "<h1>Hello from $(hostname -f)</h1>" > /usr/share/nginx/html/index.html
service nginx start
systemctl enable nginx
Step 9 — Launch. Review the Summary panel → Launch instance → View all instances. Wait until Instance state = Running and Status checks = 2/2 checks passed. Copy the Public IPv4 address.
Step 10 — Test. If you used the user-data script, open http://<PUBLIC_IP> in a browser (note: http, not https).
The browser shows a timeout?
Almost always one of: (1) security group does not allow port 80 from 0.0.0.0/0, (2) you typed https:// but no TLS is configured, (3) the web server is not running, (4) instance is in a subnet without a route to an Internet Gateway, or (5) no public IP assigned.
Why this matters for security
The security group is your first firewall. SSH from My IP only, and only 80/443 from anywhere. Never open 22, 3306 or 3389 to 0.0.0.0/0 – internet-wide scanners find such ports very quickly and start guessing passwords. Security groups are stateful (स्थिती लक्षात ठेवणारे): if inbound is allowed, the reply goes out automatically.
Ravindra Bagale's Tip
Khup students SSH rule madhe source "Anywhere 0.0.0.0/0" thevtat karan "My IP" nantar badalto. Tyapeksha ghari/class madhe IP badalla ki fakt rule edit karun My IP punha nivda – 10 second che kaam. Port 22 jagala ughda thevna mhanje darvaja ughda thevun zopne.
Lab
Launch one Amazon Linux 2023 instance and one Ubuntu 24.04 instance with the same web-sg. Paste the user data script into the Amazon Linux one and open http://<PUBLIC_IP> in the browser.