How to Enable SSM Connect in EC2 Instances 💡


Managing AWS EC2 instances without worrying about SSH keys is a big relief, and AWS Systems Manager (SSM) Session Manager makes it even easier. It provides a secure way to connect to your instances. In this guide, I will walk you through the steps to enable SSM Connect in your EC2 instances, making your cloud management more secure, efficient, and hassle-free.
Step 1: Create and Attach an IAM Role to the EC2 Instance 🍳
Navigate to the AWS IAM Console and go to Roles.
Click Create role.
Select AWS Service and choose EC2, then click Next.
In the permissions section, search for and attach the following policy:
AmazonSSMManagedInstanceCore
(required for SSM agent to communicate with AWS Systems Manager)
Click Next, give the role a name (e.g.,
SSMManagedEC2
), and create the role.Attach the IAM role to your EC2 instance:
Go to the EC2 Console > Select your instance
Click Actions > Security > Modify IAM Role
Select the IAM role you created and click Update IAM Role
Step 2: Verify SSM Agent is Installed and Running ✅
📌 Check out for SSM agent Verification details: AWS Systems Manager
For Ubuntu, run the following command to check if the agent is installed:
sudo systemctl status snap.amazon-ssm-agent.amazon-ssm-agent.service
📌 If the agent is not installed, then refer this link for installation: Manually installing and uninstalling SSM Agent
Step 3: Access EC2 Instance Using SSM 🚀
Now you can access your EC2 instance using SSM through the AWS Console or AWS CLI.
Option 1: Using the AWS Console 💻
Navigate to AWS Systems Manager Console.
Click the EC2 instance you want to access.
Click Connect.
Click Session Manager and then Connect to open a shell session.
Option 2: Using AWS CLI ⚡
To access EC2 via the local terminal or AWS CLI, install the SSM Agent on your local machine using the following commands:
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"
sudo dpkg -i session-manager-plugin.deb
For other OS versions, refer to the SSM Plugin Installation.
Run the following command to enter an EC2 machine via SSM through the terminal. 🥳
aws ssm start-session --target <instance-id>
📌 Make sure your AWS CLI is configured with the right permissions and region settings.
Conclusion 🎃
Enabling SSM Connect in EC2 instances enhances security, eliminates the need for SSH keys, and simplifies instance management. By following these steps, you can securely manage your AWS environment with AWS Systems Managers “Session Manager”.
📬Do you have any questions or need further assistance? Leave a comment below or explore my other AWS tutorials for more cloud management tips!
Subscribe to my newsletter
Read articles from Gerlyn M directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Gerlyn M
Gerlyn M
Gerlyn is a DevOps engineer with a strong passion for Kubernetes and automation. He is always eager to learn and continuously strives to enhance his skills, aiming to become an expert in the field. He loves to share his knowledge with the community.