The operating system of your local computer determines the options that you have to connect from your local computer to your Linux instance. Here are directions to connect from Windows Using PuTTY or OpenSSH, From Linux & MacOS-X using ssh client and from Windows Subsystem for Linux (WSL) using ssh client.
Connecting from Windows using PuTTY
We will now use the private .ppk file of the key pair generated earlier to open a SSH session to the EC2 instance.
Start the PuTTY application.
Enter in the IP address of the EC2 instance in the Host Name (or IP address) field.
To save the session (so we dont have to repeat the configuration everytime) provide a name in the Saved Sessions field.
In the left navigation pane under Connections clickon SSH and next click on Auth.
In the Private key file for authentication field click Browse and browse in the .ppk file downloaded when creating the key pair earlier.
Next in the left navigation pane click on Session (scroll up if you need to) and and further click on Save to save the session.
Next click on Open to start the SSH session.
PuTTy will now attempt to start an SSH Session.
NOTE: You will get a security Alert The Servers host key is not cached in the registry, click on Yes to continue.
You will now be presented with the login as prompt.
At the login as prompt type ubuntu and hit enter.
You would have now logged into the EC2 instance on AWS.
Connecting from Windows using Windows Subsystem for Linux
We will now use the private .pem file of the key pair generated earlier to open a SSH session to the EC2 instance.
cp /mnt/<Windows drive letter>/path/my-key-pair.pem ~/WSL-path/my-key-pair.pem
NOTE: Username to be used here is ubuntu.
sudo ssh -i /path/my-key-pair.pem ubuntu@<ip-address>
You will see the following response:
The authenticity of host '<ip-address>'
can't be established.
RSA key fingerprint is 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f.
Are you sure you want to continue connecting (yes/no)?
you will now be logged into the EC2 Instance.
Connecting using SSH on Linux & MacOS and OpenSSH on Windows
We will now use the private .pem file of the key pair generated earlier to open a SSH session to the EC2 instance.
ssh -i /path/my-key-pair.pem ubuntu@<ip-address>
You see a response like the following:
The authenticity of host 'ec2-198-51-100-1.compute-1.amazonaws.com (198-51-100-1)' can't be established.
ECDSA key fingerprint is l4UB/neBad9tvkgJf1QZWxheQmR59WgrgzEimCG6kZY.
Are you sure you want to continue connecting (yes/no)?
You will now be logged into the Instance.
NOTE: You might need to change the permissions of the key file by running the chmod command as follows
chmod 600 /path/my-key-pair.pem
For detailed directions on these please have a look at the following links:
PuTTY, Windows Susbsystem for Linux, MacOS-X ssh Client, Linux ssh client