To connect to an EC2 Linux Instance from a Windows PC, you can use:
i)The native secure shell (SSH) client on Windows 10 — Windows PowerShell
ii)Putty or
iii)Google Chrome Secure Shell Plugin
Connecting via Putty is widely documented thanks to Putty’s popularity. However, when connecting to a Linux instance via Chrome’s Secure Shell App, the information is a tad scarce.
Neither client is markedly better than the other, but mastering both gives you options.
So ,What is Chrome’s Secure Shell App?
Secure Shell is a Google Chrome App that merges the secure shell protocol with a “hterm” terminal emulator to provide an SSH client for the Chrome Browser— Chromium.googlesource.com
What Does This Mean?
A secure shell protocol is a set of rules that govern how one can securely connect and communicate with a remote machine.
On the other hand, an SSH client is a software program that implements this protocol.
Think about it this way; assume you have two tables that are approximately 40 inches apart. One table holds glasses, and the other one is empty. In addition, there is a network/path that connects the two tables.
Any rules one can come up with to connect to the empty table and move the glasses (the glasses are the data) from table A to table B without breaking them and without a malicious person snatching the glasses while they are in transit (secure communication) is a protocol.
Now, if one was to develop a software that implements these rules to facilitate the actual connection and movement, then this software becomes a client — similar to how the Chrome Secure Shell App implements the SSH protocol.
Finally, “hterm” or HTML terminal is a terminal emulator. A terminal emulator gives you an interface that allows you to communicate with the underlying infrastructure.
With that understanding, time to launch an instance and connect to it.
1. Launch an Instance
- Log into your AWS account
- Navigate to the EC2 service
- Launch an instance as shown below
- Ensure you choose a Linux Amazon Machine Image (AMI) e.g. the Amazon Linux 2
- Follow the prompts up to the last step, which asks you to download your private key file. Give your key pair a name and download it.
- Save the private key file in a secure directory. Note that you can only download this file once, and you cannot connect to your instance without it.
2. Download Chrome’s Secure Shell App
- Ensure that you have Google Chrome in your PC first.
- Search Secure Shell App on Google and add the App to chrome.
- To launch the Secure Shell App, navigate to chrome://apps/
- Double click to open and you will encounter this interface.
- Add the user name
- Go back to AWS, copy the IP address of your instance and add it as the hostname
3. Generate the Public Key File
Remember, when launching the instance, you only downloaded one file, which is a .pem file.
Since both private and public keys are required, you must first generate the public key from the private key file.
To do so:
- Launch command prompt in your Windows 10 PC
- Navigate to where you stored your private key file. In my case, it was Downloads directory, so the command will be “cd downloads.” If you saved your file in, let’s say Documents, then the command will be “cd documents.”
- Next, you can type the command “dir” to list the files in your directory and confirm your private key file is indeed there.
- It is finally time to generate the public key file
- Use the command ssh-keygen –y –f MyKP.pem > MyKP.pub (This means you are generating the public key file from the private key file)
Before Proceeding Please Note:
How to Use ssh-keygen on Windows PC When You Have MS Publisher
The .pub extension is the recommended syntax for the public key file. However, if you have MS publisher installed in your PC, then you know that Publisher uses the .pub extension.
That means your public key file will be a Publisher file, and that may lead to issues.
Therefore, you can add a letter at the end of .pub. For instance, add a “k” and use pubk as your extension instead. Your command will thus be ssh-keygen –y –f MyKP.pem > MyKP.pubk as shown below.
Remember that ultimately, it is not so much how you name it, but the content of the file. The content remains the same irrespective of the extension.
4. Remove the .pem Extension
- Next, you must remove the .pem extension from the private key file. This is an incredibly important step (arguably the most important) because if you do not, you will not be able to connect to your instance.
- To remove the extension, rename the file using this command: “ren MyKP.pem MyKP” then hit enter
5. Import The Your Key Pair (Public and Private Keys) to Confirm Your Identity
- Go back to you Secure Shell App on your Google Chrome browser and click import
- If the identity field does not auto-fill, close the Secure Shell and launch it again
- Refill the details and when you get to the Identity Part, click on the page down arrow and select the private key file.
- With that done, hit enter
- You will be prompted if you are sure you want to continue connecting, type “yes” and the connection will be established
- You are ready to start using your AWS instance.
- Some of the things you can do include installing a web server.
Final Word
There you go, you don’t have to struggle anymore when connecting to an AWS Linux Instance using Chrome’s Secure Shell App.
Remember you can follow the same procedure with slight variations to connect to any other remote machine using Secure Shell App