Use discount code EARLYBIRD20 and get up to 20% OFF Buy Now ×

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

Screen Shot 2021-05-25 at 11.37.07 AM
DevOps

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

Let’s learn how to connect to an EC2 instance running in AWS from your local machine. Your local machine can be Windows laptop or MacBook laptop.

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.

Copy the url from SSH which looks like below:
For e.g.
ssh -i “mykey.pem” ubuntu@dns_name.compute.amazonaws.com
Watch steps in YouTube channel:


Windows Laptop instructions
5. Go to your local machine, Open Git Bash in Windows

 

make sure you are in downloads directory where your keys got downloaded. Type the below commands:
type below commands:
pwd
this should tell you which directory you are and then navigate to downloads dir.

cd  ~/downloads

Now copy the value from Example in the above screenssh -i “mykey.pem” ubuntu@dns_name.compute.amazonaws.com

and then type enter, say yes and enter

 

Mac Book Laptop or iMac Instructions
Open iTerm window, type the below command to go to downloads directory.
cd downloads
For few Mac laptops, it may add .txt in the end of pem file. in that case you need to remove .txt in the end

pwd
and then execute below command to make sure the keys have only read permissions.
chmod 400 *.pem
6. Paste the url from example highlighted above in step # 4.
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.

 

Leave your thought here

Your email address will not be published. Required fields are marked *

0
    0
    Your Cart
    Your cart is emptyReturn to Shop