Day 2. AWS - EC2


How I Connected to My EC2 Instance via SSH (macOS & Windows)
So, after launching my first EC2 instance yesterday (still feels cool to say that 😄), I realized the next thing I needed to do was connect to it. I’d heard the term SSH before, but I hadn’t used it much. This part felt a bit intimidating at first — but turns out, it wasn’t that bad.
Here’s how I did it.
Step 1: Found My PEM File and Public IP
AWS gave me a .pem
file when I launched the instance. I had saved it in a folder on my desktop. I also noted down the public IP of the instance from the EC2 dashboard — without it, I wouldn't know where to connect.
Since I’m on macOS, I Tried the Terminal First
I opened the Terminal app and went to the folder where my .pem
file was.
cd ~/Desktop/aws-stuff
But then the first issue hit me — permission denied. I Googled it, and turns out I had to restrict access to the key file. So I ran:
chmod 400 my-key.pem
That did the trick.
Then I tried connecting:
ssh -i "my-key.pem" ec2-user@<EC2_PUBLIC_IP>
Boom 💥 — I was in! It felt amazing seeing that EC2 shell prompt.
Then I Tested It on Windows (For Practice)
I also wanted to try this from my Windows laptop, just to see how different it is.
The .pem
file doesn’t work directly with PuTTY, so I had to convert it using PuTTYgen. At first I didn’t know this, so I downloaded PuTTY and wondered why it wouldn’t accept my key.
So I did this:
Opened PuTTYgen
Loaded the
.pem
file (had to select “All Files” to see it)Clicked Save private key, and it gave me a
.ppk
file
Then, in PuTTY:
I entered my EC2 public IP as the hostname:
ec2-user@<EC2_PUBLIC_IP>
In the SSH > Auth section, I browsed for my
.ppk
file
When I hit Open, it asked me to trust the server (clicked Yes), and then I was inside the EC2 instance. It worked on Windows too!
A Few Things That Tripped Me Up
The permission thing on macOS was weird at first. That
chmod 400
command saved me.On Windows, I didn’t know PuTTY needed a
.ppk
key instead of.pem
.I almost forgot to open port 22 in the security group. Luckily, I had read somewhere about SSH needing it. I added a rule to allow SSH from my IP.
What I Learned 🧠
This whole process taught me a few cool things:
SSH is actually not that scary
AWS doesn’t let you re-download the key, so saving the
.pem
file properly is super importantThe same EC2 instance can be accessed from macOS and Windows with the right steps
What’s Next?
Now that I can connect to my EC2 instance, I want to try setting up a simple web server on it — maybe NGINX or Apache, just to see how it works. That’s probably going to be my Day 3 blog.
Subscribe to my newsletter
Read articles from satyam mishra directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
