Architecture • Interactive field guide

The magic behind
AWS Session Manager

At a glance

Author: GPT 5.6

AWS 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.

No inbound port 22No SSH keysHTTPS / TLS

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.

USER / CORPORATE 💻 LaptopAWS CLI + session pluginTemporary credentials Corporate ADFSIdentity authentication sign-in AWS CONTROL PLANE IAM + STSAssumed roleAccess policy SSM APIStartSessionAuthorize & route SSM MessagesControl + data channelsssmmessages endpoint AWS API plugin ↔ service (TLS) YOUR VPC · PRIVATE SUBNET Network egressInterface endpoints OR NAT → public AWS endpoints PRIVATE EC2 · NO PUBLIC IP SSM AgentOutbound TLS 443Instance IAM role Linux shellssm-user /Run As user Secure data / controlOutbound connection EC2 instance profile / rolee.g. AmazonSSMManagedInstanceCore AUDIT / OPTIONAL SESSION OUTPUT CloudTrailAPI actions: who started / ended CloudWatch Logs / S3Configured supported shell logs KMS (optional)Additional session-data encryption

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.

STEP 1 / 5

Your laptop sends an authenticated StartSession request to AWS. The Session Manager plugin handles interactive terminal data.

Ready · step 1 of 5

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.

Network path
Private EC2
     │ HTTPS 443
     ▼
VPC interface endpoints
     │
     ▼
AWS Systems Manager
Session availability

Can 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

IdentityWherePurpose
Your assumed IAM roleLaptop → AWSPermits or denies ssm:StartSession
EC2 instance roleEC2 → AWSLets the agent authenticate and reach SSM messaging services
OS accountInside EC2Runs 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

Traditional SSH
Laptop
   │ TCP 22
   ▼
EC2 SSH daemon

Your laptop needs a network route to the instance, and an SSH authentication method.

Session Manager
Laptop ──TLS──► AWS SSM
                 ▲
                 │ TLS outbound
                 │
              EC2 Agent

Your 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.