Part 3 of 12 — 12 Hands-On AWS Projects
Introduction
Every cloud engineer spends part of the day inside a Linux terminal. Servers do not have screens and mice — you talk to them over SSH. In this project I will launch a Linux EC2 instance and connect to it from my laptop, using four different tools: Git Bash, Command Prompt, PuTTY and MobaXterm. They all do the same job, and by the end you will know which one you like best.
What you will build
- A Linux EC2 instance you can log into
- A key pair for secure, password-free login
- A security group that allows SSH on port 22
- Working connections from four tools: Git Bash, Command Prompt, PuTTY and MobaXterm
Architecture
Your laptop connects over SSH (port 22) to the EC2 instance, using your private key file.
Prerequisites
- An AWS account (the free tier works for this project)
- An EC2 key pair created in the AWS console (download the
.pemfile and keep it safe) - One or more of these installed: Git Bash, PuTTY, MobaXterm (Windows Command Prompt already has SSH built in)
- Basic comfort with the terminal
Steps
1. Launch the EC2 instance
From the AWS console, launch an Amazon Linux instance. Choose your key pair, and pick a security group that allows SSH on port 22 from your IP address. If you allow it from anywhere (0.0.0.0/0), it works too, but limiting it to your own IP is safer.
2. Note the public IP
After the instance starts, copy its public IPv4 address from the console. You will need it for every connection below.
3. Protect your key file
SSH refuses to use a key file that anyone else can read. On Git Bash, set the permission first:
chmod 400 my-key.pem
Replace my-key.pem with your own key file name. On Windows, right-click the file, open Properties, and remove access for other users if needed.
4. Connect with Git Bash
Git Bash is my usual pick on Windows because it feels like a Linux terminal. Run:
ssh -i my-key.pem ec2-user@<Public-IP>
Replace <Public-IP> with your instance public IP. The first time, SSH asks if you trust the host — type yes. You should land on the EC2 prompt.
5. Connect with Command Prompt
Windows 10 and 11 already have OpenSSH built in, so the same command works in cmd:
ssh -i my-key.pem ec2-user@<Public-IP>
Run it from the folder where your .pem file is, or give the full path to the key file. If the command is not found, turn on the OpenSSH Client in Windows optional features.
6. Connect with PuTTY
PuTTY cannot use a .pem file directly, so convert it once with PuTTYgen:
- Open PuTTYgen, click Load, and pick your
.pemfile. - Click Save private key and save it as
my-key.ppk. - Open PuTTY, enter the public IP as the host, port 22, connection type SSH.
- Go to Connection, SSH, Auth, and browse to your
.ppkfile. - Click Open, and log in as
ec2-user.
7. Connect with MobaXterm
MobaXterm is handy because it gives you a terminal plus a file browser in one window:
- Click Session, then SSH.
- Enter the public IP as the remote host and
ec2-useras the username. - Tick Advanced SSH settings and pick Use private key, then browse to your
.pemfile. - Click OK. You are in, and the left panel shows the server files.
8. Check you are in
Once connected, run a few commands to confirm everything works:
whoami
uptime
df -h
You should see ec2-user, how long the server has been up, and its disk space.
If it does not connect
- Permission denied: you are using the wrong key file, the wrong username, or the key permission is too open. Amazon Linux uses
ec2-user; an Ubuntu image usesubuntu. - Connection timed out: the security group does not allow port 22 from your IP, or the instance is still starting. Check both.
- Key file not found: you are running the command from a different folder than the
.pemfile. Use the full path.
What you learned
- How key-based login works, with no password involved
- Why the
.pemfile must stay private and protected - How each SSH client does the same job in a different way
- How a security group acts as a firewall for your server
- How to check a Linux server once you are inside it
Cleanup
When you are done practising, terminate the instance from the console so it stops billing. If you want to practise again later, stop it instead of terminating it — a stopped instance keeps its setup but costs nothing for the server itself. Keep your key file somewhere safe for next time.
Try next
In Project 4, we use this same SSH connection to host a Netflix-style landing page on EC2 with Nginx.
About Cloud Messenger — Learn • Build • Visualize • Troubleshoot • Grow | cloudmessenger.in | linkedin.com/in/cloud-messenger | github.com/Cloud-Messenger | #buildwithCloudMessenger

Top comments (0)