How to Create EC2 instance for Linux Machine in AWS and How to Access that Machine Through PuTTY.
Tags: aws, linux, devops, ec2
Published: 2023-11-01 11:33:09


How to Create EC2 instance for Linux Machine in AWS and How to Access that Machine Through PuTTY.

In this lab we will explore how to create linux ec2 instances in aws and how to access that machine through putty software and how to terminate the linux machine.


**Step1:** Go to your **AWS Management Console** and select a region where you want to create an instance of Windows machine.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r58r4c8eq0daf4aohn4w.png)

---

**Step 2:** Now go to the search bar and type EC2 . Then you will find **EC2** service and click on it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqgbmdz6v1bi2ed2byoi.png)

---

**Step 3:** You will find EC2 Dashboard like this image and click on **“Launch instance”**. You can also create instances by clicking the **“Instance (running)”** option.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9egqbgz8wfk7wb4ch4ya.png)

---

**Step 4:** Now you will find the Launch an instance page for filling up necessary information for creating a Linux instance. Follow the below instructions : 

⇒ Provide the name of your Linux machine. Here I provided a name as “linux-ec2”.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4m0wjei5bb4t6owgou5.png)

---

⇒ Select your desired Linux machine. I selected Amazon Linux and I am using free tier eligible service.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6po9kpe083kjwiplys3v.png)

---

⇒  Select your desired instance type. I selected **t2.micro** type which is free. You can also take other instance type by clicking **“compare instance types”**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tb1duq6geurv2651i2c.png)

---


⇒  Now you have to create a login key pair for login through **PuTTY**. Click on **“Create new key pair”**. And you will find a window.  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/181qnthm7w9tsyrho5g6.png)

---


⇒ Provide a key pair name, key pair type RSA and private key file format should **.ppk **accessed through **PuTTY**. By this key pair you can access your Linux machine through PuTTY. Now click on **“Create key pair”** and the key pair will be downloaded. The key pair must be saved in a secure place.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvjbuhuk3nugve06s2bo.png)

---

⇒ Now Setup your Network settings. Click on the **“Edit”** button to enable the edit option. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enq8ilxwplmmqzz30xh7.png)

---

⇒ Now select a **VPC** . I selected a default **VPC (Virtual Private Cloud)**. Then Select Subnet in your availability zone (or you can create a new subnet). Then Enable **“Auto-assign public IP”**. Now create a **security group** or you can use default security group or newly created security group by selecting existing security group option. I created a new security group. Provide a security group name and description as your purpose.  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pegwykoiow5jnh8eoe3.png)

---

⇒ Now add **inbound security group rules**. Click on the **“Add security group rule”** button .


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jys2xbco0n9cp3xklgb2.png)

---

⇒ Now add Inbound Security Group Rules for public access. Add Rules for **SSH (port: 22), HTTP(port: 80)** and assign source type anywhere so that anyone can send requests and get responses from anywhere via Internet. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/itpg9thd56uaskgzu359.png)

---


⇒  You can configure storage from this **storage setting**. And There is an **Advanced details** option for allowing advanced configuration. In this Lab we are not going to set up this advanced feature.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xm1awtnjohh61d8edmgm.png)

---

⇒ Now click on **“Launch instance”**. After that Linux ec2 instance will be created within a few seconds.  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pizn51ktfhlyezmv6z2r.png)

---

⇒ Now click on **“View all instances”**. After that will be redirected to the instances list page. Where your will find all instances.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfmn7y12ldfxjofydqhc.png)

---

⇒ Wait until the status **2/2 checks pass** . It means your instance is ready to use.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zx1hd1tkh3bcynroi4gy.png)

---

**Step 5:** Select **“linux-ec2”** machine and Click on the **right bottom** upper sign icon for the details of the ec2 machine.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ekv2gt81nxm98mzu8ko.png)

---



⇒ Now copy the **public ip** address for login with PuTTY.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n1vy2d8td879pyrzs96y.png)

---



                      **Access Through PuTTY**

---

**Step 6:** Go to google and search putty download for windows. And go to www.putty.org then click on **“Download PuTTY**”. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x653ykgjlqpql18xvgkk.png)

---

⇒ Download the **putty.exe** file according to your computer configuration
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90aop7687xmldfk39nhj.png)

---


⇒ Open **putty.exe** file by double click.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ttkvoms01okn826dxgde.png)

---


⇒ your will find this window as like as below image.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1k8chaetay0azeq6m8q0.png)

---


⇒ Click on **+SSH** tab 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dm89q795fza0u221tpes.png)

---

⇒ Then Click **+Auth > Credentials**. You will find your computer browsing option. Click on Browse. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okhphtlakd1vzt6lfpif.png)

---


⇒ Now upload your **ec2 machine’s private key** when you downloaded it at the time of creating an ec2 instance. Now Scroll up and find **“Session”** tab


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as25zfh2fls64snvjk10.png)

---


⇒ Click on **“Session”** tab and put your ec2 machine’s public IP address (follow step 5 for getting public IP address) and click on **“Open”**.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ushnckpjr7e5f7iduwck.png)

---


⇒ Click on **“Accept”**.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jcee0zd2nbzxm93piwc.png)

---


**Step 7:** Now will find your ect2 instance Linux machine’s terminal. For login type: **ec2-user** and press enter.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36op92k2ml0bxyhylf6s.png)

---


⇒ Now you are eligible to access Linux ec2 instance of your AWS account

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/liwmw6279yahcl5p7so5.png)

---


⇒ Create a text file for testing.
→ `touch testfile`
→ `ls`


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vehitofmiyv4v1f6dkxm.png)

---


                   **Terminate This EC2 Machine**

---


**Step 8:** Go to Instances list page  and click on **“Instance state”** and click **“Terminate instance”**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7lew5juaxxr61jm1j5v.png)

---


⇒ Click on **Terminate**. The Linux ec2 instance machine will be terminated within a few seconds.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ynnnfssega2zpsih3bj.png)

---


                      **Thank You and Pray for me**

Related Keywords: 
AWS EC2 instance creation for Linux;
How to create EC2 instance in AWS;
Linux EC2 instance setup on AWS;
Access AWS EC2 Linux instance with PuTTY;
Connecting to AWS EC2 Linux using PuTTY;
Step-by-step guide for AWS EC2 Linux setup PuTTY;
AWS EC2 SSH connection PuTTY tutorial;
AWS EC2 PuTTY private key setup;
Amazon Web Services EC2 Linux instance SSH access;
AWS EC2 Linux machine configuration for PuTTY access;

Kamrul devops; kamrul-hasan-devops; kamrul-hasan-aws-solution-architect; kamrul-devops; kamrul-cloud; kamrul-hasan-devops; kamrul-devops-engineer; devops-engineer; kamrul-hasan-devops-engineer;