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


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.
Subscribe to my newsletter
Read articles from Kaustav Dey directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
