Accessing AWS EC2 instance via Windows 10 Bash Shell

For all Linux users, who need a proper Linux shell on your Windows machine!

As you may aware the latest Windows 10 version(s) do support in built Linux distros for your own experiments. As a native Linux user, this has been a god send to me when I tend to use Windows machines occasionally. Mainly because of this feature, I use Windows nowadays more than I ever used it :)

Over the years, I have been used to use native SSH command, which by default comes with Linux distros to connect to cloud virtual instances. I used to love it since it has been just one command execution.

With the Windows 10 Bash shell approach, we could do exactly the same thing by just installing Ubuntu instance on top of Windows 10.

Lets get on with the steps now!

Step 01: Create an AWS EC2 instance (t2.micro). (Just for testing purposes) Make sure to open port 22 (it is opened by default anyway).

Step 02: While creating the instance download your new PEM key to a Windows folder.

Step 03: Now move your focus to Windows desktop and do the following steps.

  • In the Windows Search box type “Turn Windows Features”. You will see the following (See Figure 01).
Figure 01
  • Now, click the “Turn Windows Features on or off” link and you will get the following window (See Figure 02). On this window, select “Windows Subsystem for Linux” and “Virtual Machine Platform” features and make sure to restart your machine.
Figure 02
  • Once the machine is restarted, go to Windows search box and move to “Microsoft Store
  • Now, search for “Linux” and you will find multiple Linux distros listed down for your choice (See Figure 03). I select “Ubuntu” here.
Figure 03
  • Now, click “Ubuntu” and then click “Get” button to install it. You will be prompted with a username and password, which you have to enter here.
  • Once you complete all this, you can search for “Ubuntu” on the search box (See Figure 04) and you will get the Linux bash shell that you need!
Figure 04

Once Ubuntu is installed on your Windows 10 machine, it is time to access the AWS EC2 instance using the PEM key, which we downloaded before.

Step 04: Open up the Ubuntu shell.

Step 05: Type “df” command to see all mount points (See Figure 05).

Figure 05

You may see C, D and E drives are mapped to the Ubuntu instance in my machine. (It may differ in your setup).

For example, if you saved your PEM file in the “D” drive, you may move to /mnt/d to find your PEM file.

Then, copy that file to your $HOME folder of the Ubuntu instance.

Step 06: Once you copy the PEM file, use chmod 400 to set the permissions.

Step 07: Finally, you may use your usual happy SSH command to control your EC2 instances.

ssh -i <pem-file> ec2-user@<ec2-instance-public-ip>

Congratulations! Now you are a Linux user who loves Windows 10!

VP Technology @ One Billion Tech, Software Architect, AWS Certified, Azure Certified, RedHat Certified