How to connect to an EC2 instance from your local machine after creating EC2 in AWS? | Connect to AWS EC2 instance from your local machine
How to connect to an EC2 instance from your local machine after creating EC2 in AWS? | Connect to AWS EC2 instance from your local machine
Pre-requisites:
1. Keys(for e.g., yourkey.pem) already downloaded in your local machine, preferably in Downloads folder.
2. EC2 instance is up and running
3. For windows laptop, you need to install Git by downloading from this URL – https://git-scm.com/downloads. For Apple laptop you need to download iTerm from here.
Steps to connect to your EC2 instance:
1. Go to AWS console.
2. Click on EC2, click on running instances link
3. Select the checkbox of EC2 you would like to connect to.
4. Click on Connect or Action, Connect. Under SSH client.
For e.g.
ssh -i “mykey.pem” ubuntu@dns_name.compute.amazonaws.com
5. Go to your local machine, Open Git Bash in Windows
Now copy the value from Example in the above screenssh -i “mykey.pem” ubuntu@dns_name.compute.amazonaws.com
and then execute below command to make sure the keys have only read permissions.
ssh -i "mykey.pem" ubuntu@dns_name.compute.amazonaws.com
7. type yes when it is asking to connect.
8. now you should be in AWS cloud, screen should show something like this, It means you are successfully connected to EC2 instance running on AWS cloud. It will also show private IP address of your EC2 instance.