The magic behind
AWS Session Manager
At a glance
Author: GPT 5.6AWS Systems Manager Session Manager lets you open a shell on a private EC2 instance without an SSH key, Linux password, public IP address, or inbound SSH port. Your IAM role authorizes the connection. The SSM Agent on EC2 uses outbound encrypted connections to AWS messaging endpoints. Session Manager carries commands and output between your laptop and the agent. The instance needs a route to AWS through VPC endpoints or a NAT gateway. The laptop and EC2 instance use separate IAM identities. The session is not a direct SSH connection.
You connect from your laptop to a private EC2 instance. You have no SSH key, no public IP address, and no Linux password. How? Your IAM role authorizes the session. An agent inside EC2 carries your shell traffic through AWS.
Complete architecture · all components
Follow the green path to establish the shell session. The orange dashed paths show optional audit and session-log destinations. The diagram is logical: it does not imply a direct connection from your laptop to the private instance.
Note: connection arrows are simplified and show functions, not individual TCP sockets. Session communication is bidirectional over agent-initiated outbound connections. The SSM API and messaging endpoints are AWS-managed services. CloudTrail logs API activity; shell transcript logging must be configured separately.
1. Follow a real session
Select any component or play the steps. The arrows show the logical control flow, not a direct network connection between your laptop and EC2.
Your laptop sends an authenticated StartSession request to AWS. The Session Manager plugin handles interactive terminal data.
Critical detail: EC2 does not accept an inbound SSH connection. Its SSM Agent establishes outbound communication with AWS Systems Manager messaging endpoints.
2. How does an isolated instance reach SSM?
Select the outbound network path available to your EC2 instance.
Private EC2
│ HTTPS 443
▼
VPC interface endpoints
│
▼
AWS Systems ManagerCan work
The instance can privately reach the required regional service endpoints (including ssm and ssmmessages). Configure private DNS, security groups, routes and IAM.
3. Three identities, three jobs
| Identity | Where | Purpose |
|---|---|---|
| Your assumed IAM role | Laptop → AWS | Permits or denies ssm:StartSession |
| EC2 instance role | EC2 → AWS | Lets the agent authenticate and reach SSM messaging services |
| OS account | Inside EC2 | Runs the shell (often ssm-user) |
Being authorized through IAM is not the same as authenticating with an EC2 Linux password. Session Manager asks its agent to start the shell for you.
4. SSH vs. SSM
Laptop │ TCP 22 ▼ EC2 SSH daemon
Your laptop needs a network route to the instance, and an SSH authentication method.
Laptop ──TLS──► AWS SSM
▲
│ TLS outbound
│
EC2 AgentYour laptop reaches the AWS API. EC2 reaches AWS from inside the private subnet. No inbound port 22 is needed.
5. Check this on your own setup
Run these on your laptop:
aws sts get-caller-identity session-manager-plugin --version aws ssm start-session --target i-0123456789abcdef0
Then run these inside the resulting EC2 session:
whoami id sudo systemctl status amazon-ssm-agent ip addr
Your corporate ADFS or IAM Identity Center login can provide temporary AWS credentials. They are not SSH keys and do not authenticate a Linux account.
6. What about audit and security?
CloudTrail can record session-management API calls. Session Manager can send supported shell-session logs to CloudWatch Logs or S3 when configured. SSH-over-Session-Manager and port-forwarding session contents do not receive normal shell-content logging.
Be careful: the default ssm-user can have sudo privileges. Restrict IAM access and configure OS-level access appropriately.