šŸ–„ļø No IDE? No Problem: How I Started an EC2 Instance Using AWS CloudShell and SSH’d in From theĀ Terminal

Kaustav DeyKaustav Dey
3 min read

There’s something empowering about spinning up your own virtual machine in the cloudā€Šā€”ā€Šespecially when you do it entirely from the command line.

No clicking through tabs. No IDE. No download-this, install-that.

Just pure terminal.

Just you and the cloud.


šŸŒ©ļø Why I Tried AWS CloudShell

As a cloud enthusiast (and someone who occasionally breaks things on my own machine), I decided to explore AWS CloudShellā€Šā€”ā€Ša browser-based terminal environment that runs right inside the AWS Management Console. No need to install the AWS CLI or generate SSH keys on my laptop. It’s preloaded, persistent, and honestly, kind of amazing.

I’d previously used EC2 through the UI, but this time, I challenged myself:

ā€œCan I launch and connect to an EC2 instance without ever leaving the terminal*?ā€*

Spoiler: Yes. And here’s how I did it.


āš™ļø Step 1: Opened CloudShell

From the AWS Console, I clicked on the little terminal icon in the top-rightā€Šā€”ā€Šthat’s CloudShell.

Within seconds, I had a shell prompt, running in a pre-configured Amazon Linux environment, with full AWS CLI access.


šŸ” Step 2: Created a Key Pair

To connect via SSH later, I needed a key pair. From CloudShell, I ran:

aws ec2 create-key-pair
  --key-name my-key 
  --query 'KeyMaterial' 
  --output text > my-key.pem

Then I set the right permissions:

chmod 400 my-key.pem

āœ… This generated a private key and saved it locally in CloudShell. No downloading needed.


šŸš€ Step 3: Launched the EC2 Instance

I picked a simple Amazon Linux AMI and started a t2.micro instance like this:

aws ec2 run-instances \
  --image-id ami-0abcdef1234567890 \  # Replace with a valid AMI ID in your region
  --count 1 \
  --instance-type t2.micro \
  --key-name my-key \
  --security-groups default

Want a specific region? Add --region us-east-1 or whatever suits your setup.

I noted the returned InstanceId because I’d need it soon.


šŸ” Step 4: Waited for the Instance and Got the Public IP

Once the instance was running, I fetched its public IP:

aws ec2 describe-instances
  --filters "Name=instance-state-name,Values=running" 
  --query "Reservations[*].Instances[*].PublicIpAddress" 
  --output text

This gave me something like:

3.145.78.123

That’s my gateway into the cloud machine.


šŸ”— Step 5: SSH’d Into My Instance

Now came the satisfying partā€Šā€”ā€Šactually connecting. Still in CloudShell, I ran:

ssh -i my-key.pem ec2-user@3.145.78.123

And boom šŸ’„ā€Šā€”ā€ŠI was in.

A full-blown Linux VM, all mine, running in the cloud, controlled 100% from the browser-based terminal. No local setup. No downloads. Just me and my instance.


🧼 Bonus: Cleaning Up

When I was done experimenting, I cleaned up to avoid extra costs:

aws ec2 terminate-instances --instance-ids i-0abcd1234efgh5678

And optionally deleted the key:

aws ec2 delete-key-pair --key-name my-key
rm my-key.pem

🧠 What I Learned

  • AWS CloudShell is perfect for CLI-based workflows, even on a Chromebook or borrowed laptop.

  • You don’t need a full IDE or even a configured local environment to manage cloud infrastructure.

  • The AWS CLI is incredibly powerful (and feels like a cheat code once you get comfortable).


šŸŽÆ Final Thoughts

Starting an EC2 instance from the terminal might seem intimidatingā€Šā€”ā€Šbut it’s actually elegant. Clean. Fast. And it gives you a deeper sense of control than the AWS GUI ever could.

If you’ve been hesitant to touch the CLI, I highly recommend giving CloudShell a try. It’s like training wheels for power users.

And once you SSH into your first cloud machine using nothing but the terminal?
You’ll never forget that feeling.

0
Subscribe to my newsletter

Read articles from Kaustav Dey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Kaustav Dey
Kaustav Dey