AWS + Linux Combo — Part 3: Connect to EC2 with SSH

By Suraj Ahir October 09, 2025 6 min read

AWS + Linux — Linux on EC2
AWS + Linux — Linux on EC2
← Part 2 AWS + Linux Combo · Part 3 of 12 Part 4 →

Your EC2 instance is running. Now it is time to connect to it. This is the moment where the cloud becomes real — you open a terminal on your laptop and type commands that execute on a server sitting in an Amazon data center somewhere in the world. That is what SSH makes possible.

What is SSH?

SSH stands for Secure Shell. It is a protocol that lets you log into a remote computer securely over a network. All data sent between your machine and the server is encrypted, so no one on the network can read your commands or the server's responses. SSH is the standard way to manage Linux servers, and it is used by virtually every cloud and DevOps engineer every day.

When you SSH into an EC2 instance, you get a command-line interface — a terminal — on that remote server. You can run any Linux command as if you were sitting in front of the machine.

Finding Your Instance's Public IP

Go to the AWS Console → EC2 → Instances → click your instance. In the details pane, find the Public IPv4 address. It looks something like 13.234.56.78. Copy this address — you will use it in the SSH command.

Connecting from Linux or Mac

Open your terminal. Navigate to where you saved your .pem key file. Run this command:

SSH Connect Command
ssh -i ~/.ssh/my-key.pem ec2-user@13.234.56.78

Replace 13.234.56.78 with your actual instance public IP. The default username for Amazon Linux is ec2-user. For Ubuntu AMIs it is ubuntu. For Debian it is admin.

The first time you connect, SSH will ask you to confirm the server's fingerprint. Type yes and press Enter. This is a one-time security confirmation.

Connecting from Windows

On Windows, you have two options. First, you can use Windows Subsystem for Linux (WSL) and run the same SSH command as above. Second, you can use PuTTY, a free SSH client for Windows. If using PuTTY, note that it uses .ppk key files, not .pem — you will need to convert your key using PuTTYgen first.

The easiest modern approach on Windows is to enable WSL (Windows Subsystem for Linux), which gives you a proper Linux terminal. Then follow the Linux/Mac steps above.

What You See After Login

After successful connection, you will see something like this:

EC2 Login Welcome Screen
   ,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'
Last login: Mon Mar 17 10:00:00 2026 from 1.2.3.4
[ec2-user@ip-172-31-10-20 ~]$

That prompt [ec2-user@ip-172-31-10-20 ~]$ is your Linux shell. You are now inside a server in the cloud.

Basic Linux Navigation Commands

Let us run some essential commands to understand where you are and what the server looks like:

Navigation Commands
# Print current directory
pwd

# List files in current directory
ls
ls -la   # detailed view with hidden files

# Change directory
cd /     # go to root of the file system
cd ~     # go to home directory
cd /etc  # go to the etc directory

# Show system info
uname -a        # kernel and OS info
hostname        # server hostname
whoami          # current logged-in user
uptime          # how long the server has been running

Exploring the Linux File System

Linux has a specific directory structure. Here are the most important directories on your EC2 instance:

Creating and Editing Files

Two of the most common tasks on a Linux server are creating files and editing them:

File Operations
# Create an empty file
touch myfile.txt

# Write text to a file
echo "Hello from EC2" > myfile.txt

# Display file contents
cat myfile.txt

# Edit a file with nano (beginner-friendly editor)
nano myfile.txt

# Edit a file with vim (powerful, but has a learning curve)
vim myfile.txt

In nano, use Ctrl+O to save and Ctrl+X to exit. In vim, press i to enter insert mode, type your content, press Escape to exit insert mode, then type :wq and press Enter to save and quit.

Installing Software on Amazon Linux

Amazon Linux uses the dnf package manager (or yum on older versions):

Install Packages
# Update all installed packages
sudo dnf update -y

# Install a package (e.g., git)
sudo dnf install git -y

# Check if git was installed
git --version

Exiting SSH Session

When you are done working on the server, type exit or press Ctrl+D to close the SSH session. This logs you out but does NOT stop the EC2 instance. The server keeps running. To stop it, go back to the AWS console and stop the instance from there.

In Part 4, we will go deeper into Linux on EC2 — covering file permissions, user management, and how to control who can access what on your server.

Building Cloud Intuition Over Time

Cloud computing is a domain where deep intuition — the ability to make good architectural decisions quickly, to diagnose problems efficiently, and to anticipate how systems will behave under load — develops through accumulated hands-on experience. Every project you build on cloud infrastructure teaches you something that cannot be learned from documentation alone. The cost surprises, the permission errors, the networking debugging sessions, the performance investigations — these are not obstacles to learning, they are the learning. The engineers who have built genuinely deep cloud intuition have usually accumulated it through many projects over several years, not from any single course or certification. Start building things, make mistakes safely in learning environments, and accumulate that experience deliberately.

Disclaimer: This content is for educational purposes only. SRJahir Tech does not guarantee any specific outcome, job placement, or exam result. Learning requires consistent effort and practical application.