To access your AWS instance, you will need “.pem” file as generated in “How to start Amazon AWS EC2 Instance ?”
Generate “.pem” file required to SSH your AWS Instance
Once you click on “Launch” you will be asked to generate key pair which you can use to “SSH” to your AWS instance.
In above, click on “Create a new key pair”
set the “Key pair name” and click on “Download Key Pair”
Accessing AWS instance over SSH using .pem file
In this post, we will show how you can ssh to your AWS Linux instance from your machine’s terminal. We have attempted to access Linux AWS instance from our Ubuntu laptop,
In below command,
- /home/devlab/Downloads/ – directory where we download the .pem file from AWS dashboard
- my-key-pair.pem – The generated .pem file when you created AWS instance
- ec2-user => The username of your AWS instance, you can find the users at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html
- public DNS name / public IP – you can get the this from your AWS instance dashboard.
ssh -i /home/devlab/Downloads/my-key-pair.pem ec2-user@my-instance-public-dns-name
Or you can use your public IP as well,
ssh -i /home/devlab/Downloads/my-key-pair.pem ec2-user@my-instance-public-ip