Skip to main content

Command Palette

Search for a command to run...

Simple Instructions for Connecting to AWS EC2 Instances

Published
3 min read
Simple Instructions for Connecting to AWS EC2 Instances
M

Hi, How are you !! Hope you doing good....

I got introduced to Cloud initially. As I went ahead learning what is cloud and how it works, then got to know a field which is DevOps that makes Cloud model more effective.

So, as I started working & got good experience on AWS. I have been learning the DevOps tool and technologies on how to use it with the Cloud, which will give me good understanding on how Cloud and DevOps go hand in hand to deploy my applications.

In the last blog we learnt, how to create EC2 Instance. Now we will learn multiple ways in which you can connect to EC2 Instance in AWS Cloud Service Provider. We will see some of those ways which can be used by the Beginners as well as used in Industry…

1st Way - Connecting using EC2 Instance connect

(It’s used for learning purpose)

  1. Select the EC2 Machine

  2. Click on connect

  3. Go to the EC2 Instance connect

  4. Click on connect

2nd Way - Using SSH Client

(It can be used for learning purpose and work purpose as well)

  1. If you are using Windows machine -> Open the cmd

  2. Change the directory to the folder where the "Key-pair" is downloaded of the machine

  3. Now select the machine, which you want to connect

  4. Click on connect

  5. Go to the SSH Client option

  6. Now copy the "ssh command given" in the cmd and hit enter and say yes

    Ex. ssh -i "test.pem" ubuntu@ec2-x-x-x-x.compute-1.amazonaws.com

    Here,

    1. ssh = Is Linux command to connect with ubuntu machine

    2. -i is the identity file "test.pem" = Is a key-pair.

    3. ubuntu = Username of ubuntu machine

    4. ec2-x-x-x-x.compute-1.amazonaws.com = DNS or IP of machine.

  7. You will be connected to the Ubuntu EC2 machine from your Windows laptop.

3rd way - Using MobaXterm.

(It best practice to connect to EC2 machines) MobaXterm is a s/w which is best practice to connect to the EC2 machine, irrespective of the OS of EC2 machine and OS of the user’s laptop.

  1. Open the MobaXterm s/w -> Click "Session" on top left corner. Then you will see lot of connections like RDP, SMTP, SSH, etc.

  2. As we want to connect to Linux EC2 -> Click on SSH ->

    In Basic SSH settings, Put the username of EC2 which will be ubuntu in the Username and in Remote Host put the DNS of Ubuntu EC2 which will be there in AWS Console SSH Client page after ‘@’

  3. Then below in "Bookmark Settings" -> Give the "Session name" as you want as "Ubuntu-First-EC2" because if we want to connect to 10 different EC2 then with the help of Session name we can differentiate.

  4. Then in "Advanced SSH Settings" -> Checkbox the "Use private key" -> Then browse the .pem file from local machine where the .pem key-pair is downloaded -> Select it and Click on Open -> Click on "OK" -> Click Accept.

  5. Done we are connected from the "Windows laptop to Linux EC2" with the .pem key-pair, instead of converting .pem key-pair to .ppk key-pair.

Conclusion

So, there are many other ways in which the EC2 Instance can be connected, like using Putty or with AWS CLI. The above mentioned steps, are beginner friendly and can be understood easily…

Hope you enjoyed and understood ways of connecting to EC2 Instance. Do like, share, comment your thoughts and feel free to connect for more information

More from this blog

Mihir's Tech blog

69 posts