![](https://nivelepsilon.com/wp-content/uploads/2025/02/ec2-ssm2-1024x490.png)
Accessing EC2 instances used to be a hassle. Bastion hosts, SSH keys, firewall rules, each piece added another layer of complexity and potential security risks. You had to open ports, distribute keys, and constantly manage access. It felt like setting up an intricate vault just to perform simple administrative tasks.
AWS Session Manager changes the game entirely. No exposed ports, no key distribution nightmares, and a complete audit trail of every session. Think of it as replacing traditional keys and doors with a secure, on-demand teleportation system, one that logs everything.
How AWS Session Manager works
Session Manager is part of AWS Systems Manager, a fully managed service that provides secure, browser-based, and CLI-based access to EC2 instances without needing SSH or RDP. Here’s how it works:
- An SSM Agent runs on the instance and communicates outbound to AWS Systems Manager.
- When you start a session, AWS verifies your identity and permissions using IAM.
- Once authorized, a secure channel is created between your local machine and the instance, without opening any inbound ports.
This approach significantly reduces the attack surface. There is no need to open port 22 (SSH) or 3389 (RDP) for bastion hosts. Moreover, since authentication and authorization are managed by IAM policies, you no longer have to distribute or rotate SSH keys.
Setting up AWS Session Manager
Getting started with Session Manager is straightforward. Here’s a step-by-step guide:
1. Ensure the SSM agent is installed
Most modern Amazon Machine Images (AMIs) come with the SSM Agent pre-installed. If yours doesn’t, install it manually using the following command (for Amazon Linux, Ubuntu, or RHEL):
sudo yum install -y amazon-ssm-agent
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent
2. Create an IAM Role for EC2
Your EC2 instance needs an IAM role to communicate with AWS Systems Manager. Attach a policy that grants at least the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:StartSession"
],
"Resource": [
"arn:aws:ec2:REGION:ACCOUNT_ID:instance/INSTANCE_ID"
]
},
{
"Effect": "Allow",
"Action": [
"ssm:TerminateSession",
"ssm:ResumeSession"
],
"Resource": [
"arn:aws:ssm:REGION:ACCOUNT_ID:session/${aws:username}-*"
]
}
]
}
Replace REGION, ACCOUNT_ID, and INSTANCE_ID with your actual values. For best security practices, apply the principle of least privilege by restricting access to specific instances or tags.
3. Connect to your instance
Once the IAM role is attached, you’re ready to connect.
- From the AWS Console: Navigate to EC2 > Instances, select your instance, click Connect, and choose Session Manager.
From the AWS CLI: Run:
aws ssm start-session --target i-xxxxxxxxxxxxxxxxx
That’s it, no SSH keys, no VPNs, no open ports.
Built-in security and auditing
Session Manager doesn’t just improve security, it also enhances compliance and auditing. Every session can be logged to Amazon S3 or CloudWatch Logs, capturing a full record of all executed commands. This ensures complete visibility into who accessed which instance and what actions were taken.
To enable logging, navigate to AWS Systems Manager > Session Manager, configure Session Preferences, and enable logging to an S3 bucket or CloudWatch Log Group.
Why Session Manager is better than traditional methods
Let’s compare Session Manager with traditional access methods:
Feature | Bastion Host & SSH | AWS Session Manager |
Open inbound ports | Yes (22, 3389) | No |
Requires SSH keys | Yes | No |
Key rotation required | Yes | No |
Logs session activity | Manual setup | Built-in |
Works for on-premises | No | Yes |
Session Manager removes unnecessary complexity. No more juggling bastion hosts, no more worrying about expired SSH keys, and no more open ports that expose your infrastructure to unnecessary risks.
Real-World applications and operational Benefits
Session Manager is not just a theoretical improvement, it delivers real-world value in multiple scenarios:
- Developers can quickly access production or staging instances without security concerns.
- System administrators can perform routine maintenance without managing SSH key distribution.
- Security teams gain complete visibility into instance access and command history.
- Hybrid cloud environments benefit from unified access across AWS and on-premises infrastructure.
With these advantages, Session Manager aligns perfectly with modern cloud-native security principles, helping teams focus on operations rather than infrastructure headaches.
In summary
AWS Session Manager isn’t just another tool, it’s a fundamental shift in how we access EC2 instances securely. If you’re still relying on bastion hosts and SSH keys, it’s time to rethink your approach.Try it out, configure logging, and experience a simpler, more secure way to manage your instances. You might never go back to the old ways.