In today’s cloud computing environment, security is a top priority. One of the most common challenges when working with Amazon EC2 instances is ensuring secure and controlled access to them. Traditionally, administrators use SSH (for Linux instances) or RDP (for Windows instances) to manage EC2 instances. However, these methods can expose instances to various security risks, such as port exposure and unauthorized access.
To mitigate these issues, AWS Systems Manager Session Manager provides a secure and scalable way to connect to EC2 instances without the need to open inbound ports, manage SSH keys, or use bastion hosts. Session Manager allows for secure, auditable shell access to EC2 instances, significantly enhancing security posture.
In this blog, we’ll explore how AWS Session Manager works and two methods to connect with EC2 instances using this tool: via the Amazon EC2 Console and the AWS CLI.
AmazonSSMManagedInstanceCore
policy. This allows the instance to communicate with AWS Systems Manager.ssm:StartSession
and ssm:TerminateSession
permissions.
sudo snap install amazon-ssm-agent --classic
sudo snap services amazon-ssm-agent
For Windows-based Systems
https://s3.amazonaws.com/session-manager-downloads/plugin/latest/windows/SessionManagerPluginSetup.exe
amazon-ssm-agent-setup.exe
) to start the installation process. Follow the on-screen instructions to complete the installation.
session-manager-plugin
For those who prefer working with the command line, the AWS CLI provides a powerful way to connect to EC2 instances using Session Manager.
Step 1: Install and Configure the AWS CLI
aws configure
Step 2: Start the Session
start-session
command. Replace <instance-id>
with your EC2 instance ID:
aws ssm start-session --target
exit
to terminate the session.AWS Systems Manager Session Manager is an invaluable tool for securely connecting to your EC2 instances. Whether you prefer using the Amazon EC2 Console or the AWS CLI, both methods provide a seamless experience with added security benefits. By eliminating the need for open ports and SSH keys, Session Manager enhances the security of your cloud infrastructure while simplifying instance management.
By integrating Session Manager into your EC2 management workflows, you can reduce administrative overhead, improve security, and ensure a more controlled access environment for your AWS resources.