SSH easily to your Ubuntu EC2 instance on AWS from Windows

Do you face the below error when trying to ssh to your ec2 instance from a Windows system?

Don’t worry 🙂

There’s a very quick and easy solution without the need to install any additional tools. Just follow the below steps:

1. Create an EC2 instance on your AWS console (if not created) and make sure you have the key-pair file downloaded on your system with .pem extension.

In my case, the name of the server is “test” and it’s running Ubuntu. Also, the name of my key-pair file is “test”.

2. Also, while creating your instance, you should have checked the “Allow SSH traffic from” checkbox and set it to Anywhere i.e. 0.0.0.0/0

3. Now, go to your .pem key-pair file. Go to its properties by right-clicking it. Go to Security tab and click on Advanced button.

4. In the Advanced Security Settings window, click on the Disable inheritance button. It will ask for confirmation. Click Remove all inherited permissions from the object.

This removes the permissions for all the users on your system for that file.

5. Now, click on the Edit button. Then click on the Add button to add the users.

6. Type in only your user name for Windows to add just you as the user to handle and modify that file.

7. As you can see, my user has been added. Now, modify the permissions for your user to allow that file to be just “Read” only. Check the box in the Allow column in front of Read.

Do not check any other box else other permissions will be activated and won’t allow your key-pair file to be securely read by ssh.

8. Click the Apply and OK buttons. Now, just where your key-pair file is located in the Windows Explorer, press Shift and holding it do a right-click. Select Open Powershell window here.

Copy the IPv4 of your EC2 instance from the AWS console.

Type this command by modifying it according to your parameters in the Powershell:

ssh -i <key-pair file location> <username>@<hostname or IP address>

For eg, the command for me is:

ssh -i test.pem [email protected]

And, That’s it!!

You have successfully SSHed into your EC2 instance on AWS from your Windows system! 🎉✨

Leave a Reply