Step By Step Guide to connect EC2 instance using Session Manager in amazon web service.

Hello,in this blog will discuss how to connect AWS EC2 instance using Session Manager on AWS Management Console.AWS Session Manager is a new interactive shell and CLI that helps to provide secure, access-controlled, and audited Windows and Linux EC2 instance management.We do not need to manage SSH keys, or use bastion hosts & open inbound ports like 22 for ssh.

The Difference between SSH & SSM are given below:

With SSH,need to open 22 port number to login EC2 instance using SSH keys whereas With SSM,need to create a IAM Role to connect EC2 instance.

There are some steps to connect EC2 instance using Session Manager (SSM):

Launch a EC2 Instance on AWS Console

  • First we need a EC2 instance on AWS.
  • Create or launch a EC2 instance,click on the below following URL:

  • Here is the output.

Create a IAM Role for Session Manager

  • Go to Service.
  • Click on Security,Identity & Compliance then select IAM.

  • Click on Roles.

  • Click on Create Role.

  • Select AWS Service as a trusted entity.

  • Allow an AWS Service like EC2 for use case.
  • Click on Next.

  • Search & Select AmazonSSMManagedInstanceCore policy.


  • Click on Next.

  • Provide a Role name.

  • Click on Create Role.

  • Role is created successfully.

Attached Created Role to EC2 Instance

  • Go to Compute service then select EC2.
  • Click on Actions.

  • Select Instance Settings then select Attach/Replace IAM Role.

  • Select Created IAM Role.

  • Click on Apply.

  • IAM Role operation succeeded.
  • Click on Close.

Connect/Login EC2 Instance Using Session Manager

  • Click on Connect.

  • Select Session Manager.

  • We are getting some error “We were not able to connect to your instance”,because AmazonSSMManagedInstanceCore policy is not activate.

  • It will take 5-10 min approx.
  • After some time,again try to connect.
  • Click on connect then session manager.
  • Now,Session Manager is successfully enabled.
  • Click on Connect.

  • EC2 instance is connected using session manager.

  • Run the following commands:

sh-4.2$ sudo su
yum update

  • Here is the command output.

Leave a Reply