How to do it…

Follow these steps to log in to your instance using Systems Manager Session Manager:

  1. Systems Manager needs permissions to access your instance, so you will need to create an instance profile and associate it with the instance. Instance profiles are containers for roles that apply to all applications running on the instance and are used to avoid the need for storing access keys and secrets on the machine. First, go to the Identity and Access Management (IAM) dashboard, select Roles, and then click Create Role.
  2. Choose EC2 as the service that will use this role and click Next: Permissions.
  3. Search for and select AmazonEC2RoleforSSM:

AmazonEC2RoleforSSM
  1. Click Next: Tags and then Next: Review.
  2. Name the role MyEC2RoleForSSM and click Create role.

 

  1. Go back to the EC2 dashboard and select your running instance. Click Actions > Instance Settings > Attach/Replace IAM Role:

Attaching an IAM role to an EC2 instance
  1. On the following screen, select the role you just created and click Apply.
  2. Go to the AWS Systems Manager dashboard:

AWS Systems Manager dashboard
  1. Select Session Manager from the menu on the left-hand side of the screen, and then click Start Session. You should see your EC2 instance in the list of available instances. If you don't see it, wait a few minutes and refresh the screen since it might take a while for Systems Manager to notice that you added the instance profile to your instance:

Starting a session
  1. Select the instance and click Start session. A Terminal session will open in a new tab:

A Systems Manager Session Manager Terminal window
  1. Terminate the EC2 instance to avoid future charges if you don't have any further use for it.

Session Manager is a great tool that simplifies gaining access to your EC2 instances, thus improving security by removing the need to manage an externally stored key pair.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset