Last updated on September 21st, 2021 at 11:08 am
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 ec2-user@my-ec2-public-ip.amazonaws.com e.g, ssh -i tmp/myKey.pem root@ec2-198-51-100-1.compute-1.amazonaws.com
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.
Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.