Beginner's Guide: Connecting to Your EC2 Instance Using AWS Systems Manager (SSM)
Tags: linux, aws, cloud, beginners
Published: 2024-04-26 13:17:11

Welcome to another beginner-friendly guide on connecting to your EC2 instance using AWS Systems Manager (SSM). So say hello to hassle-free, secure connections with just a few simple steps!

**Step 1: Create an IAM Role:**

Search and navigate to the IAM (Identity and Access Management) dashboard in the AWS Management Console.

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

Select "Role" on the left hand side of your screen and click "Create role"

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

 Create a new IAM role with the necessary permissions for EC2 following the screenshots below.

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

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

In the searchbox displayed on the next page, search for "managedinstance", select the result displayed and click next.

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

Name your IAM role accordingly. I named mine "EC2-SSM-MANAGED-INSTANCE-CORE", leave everything else as is and scroll down to click create role. 


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



**Step 2: Launch EC2 Instance:**

Search for "EC2" in the search bar and click "instances".

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

Select "Launch instance" and follow the screenshots below.

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

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

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

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

Make sure to still select an existing keypair or create a new one because it's still needed.

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

You can also notice that in the screenshot above I am unticking the "Allow SSH traffic from" box.

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

Click on "Advanced details" tab and select the IAM role you created earlier in the "IAM instance profile" section below, click create instance and wait for your instance to launch.

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

**Step 3: Connect to your EC2 Instance via SSM:**

Once your instance in done creating, select it and click connect above.

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

Make sure to select "Session Manager" as the connection mode and click connect below.

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

After that, a terminal should pop up in a new tab on your browser which eliminates the need of having to ssh directly to your linux box and reduces security risks.

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

**Please remember to delete the EC2 instance after use so as to not incure cost on your AWS account. Do not worry about the IAM ROLE created as this is free and can be used repeatedly**