Here’s how you can connect to Amazon EC2 Linux instance from your Linux/Mac laptop using SSH:
Step 1: Create amazon ec2 instance with a new key pair
Step 2: Save your private key to a known location (it’s a .pem file you’ll download in the process)
Step 3: In the EC2 dashboard go the the security group settings for the instance and open ssh port 22
Step 4: Make sure the folder with the private key has appropriate access otherwise it won’t work (e.g, chmod -R 700 path/to/key).
Step 5: Type the following in shell:
ssh -i path/to/key/myKey.pem email@example.com e.g, ssh -i tmp/myKey.pem firstname.lastname@example.org
You may see the warning (e.g, public ip of Amazon EC2 instance is ‘198.51.100.1’)
The authenticity of host 'ec2-198-51-100-1.compute-1.amazonaws.com (10.254.142.33)' 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)?
Step 6: Enter yes
Warning: Permanently added 'ec2-198-51-100-1.compute-1.amazonaws.com' (RSA) to the list of known hosts.