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 navgation 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 ec2-user if your image is Amazon Linux OS or ubuntu if your image is Ubuntu Linux OS and hit enter.
You would have now logged into the EC2 instance on AWS.
Connecting from Windows using MobaXterm
We will use the private .pem key pair to open an SSH session to the EC2 instance.
Start the MobaXterm application.
To open a session, click on Session in the top-left corner, then click SSH.
Enter in the IP address of the EC2 instance in the Host Name field.
To the right, select username and enter your username for the session.
NOTE: Username to be used here is ec2-user if your image is Amazon Linux OS and ubuntu if your image is Ubuntu Linux OS.
Below, click on Advanced Settings, and select private key (use your .pem file).
Click Ok.
MobaXterm will have logged you in to your EC2 instance.
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 ec2-user if your image is Amazon Linux OS and ubuntu if your image is Ubuntu Linux OS.
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.
NOTE: Username to be used here is ubuntu if your image is based on the Ubuntu Linux OS and ec2-user if your image is based on Amazon Linux OS. (See this page which covers many of the common AMI OSs.)
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. Edit to match your path and key pair name.
sudo 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