How to securely connect EC2 via SSH with AWS Systems Manager

Modern best practice to connect Amazon EC2 instance via SSH without SSH key/password and with closed inbound 22 port. AWS Systems Manager Session Manager tutorial.

Table of Contents

Step 1: Launch Amazon EC2 Instance

Step 2: Create AWS IAM Role

Step 3: Connect Amazon EC2 via SSH

$ aws ssm start-session --target INSTANCE_ID
$ aws ssm start-session --target i-06fd9f063a7cf53fd

Extra: Connect using SSH command and SSH key

$ sudo yum install -y
$ ssh -i SSH_KEY ec2-user@INSTANCE_ID
$ ssh -i key.pem ec2-user@i-077b1f947c98988d5


Python Developer and Artificial Intelligence Engineer