How to connect to EC2 from Windows using SSH or using EC2Connect ?

Rohan Vania
4 min readJul 16, 2024

--

There are different ways to connect to EC2 from your machine. I will show you two ways to connect from windows.

  1. Using SSH
  2. Using EC2 Connect (Very Easy) in AWS Dashboard.

While launching a instance in AWS, I created a key-value pair which gets downloaded in your local machine.

RSA and ED25519 are just different encryption algorithm.

Since, we will be connecting through OpenSSl we choose .pem file. What is OpenSSL? Its just a shell or in high level a computer program that exposes an OS services to a user.

From one shell, we will connect to another shell that’s, why we download a private key and public key which we will use to connect to our EC2 instance. Before this check if SSH works in your machine.

SSH working in the machine

If it doesn’t make sure it work, one way is, in windows got to Settings>System>Optional features>Add a feature> Open SSh Client

Search features you want

In most cases, this will work, If it doesn’t paste the error and there are lots of resources available to help you. (One of the best skill to become good in problem solving)

After this, AWS has given a syntax to connect

ssh -i /path/key-pair-name.pem instance-user-name@instance-public-dns-name

I have downloaded the key in Downloads folder.

In my case I have already, added the key before, but when you run this command it will save it in host and add a fingerprint your confirmation and give you this permission denied error.

What exactly is this error? So, basically this error is because all user can read your file, user in the sense I mean, when you start your PC you can many users, like guest, user1, user2, admin etc. So all have access to this file. And In order for SSH connection to work file should have only read and execute permission for one user.

Let’s do that click right on .pem file that you have downloaded > Click Security Tab > Advanced option > Disable inheritance > Remove all > Add user > Select principal > search your user > Add read and Read &execute > Apply > ok

We can do this in linux using a command:

chmod 400 "mediumkeypair.pem"

Then, run the command again.

🐱‍🏍Hooray!!, We are connected to EC2 machine using Windows local machine.

Instead, of doing all this, you can go to instance dashboard and click connect and Done. 😁 (But this will open in dashboard of aws)

🙏 Thank you for reading, and please follow me on Medium for more articles in simple, easy-to-understand language. Follow me on LinkedIn for any queries: https://ca.linkedin.com/in/rohanvania

#TechTips #AWS #WebDevelopment #NextJs #ExpressJS #DevOps

--

--