ssm start session is a command-line tool in AWS Systems Manager that establishes a secure, encrypted connection to an EC2 instance without requiring public IP addresses, SSH keys, or firewall rules.
The command initiates a session through the AWS Systems Manager Session Manager service, which uses a reverse connection model. Instead of exposing the instance to inbound traffic, the instance connects outbound to the Session Manager endpoint. This design eliminates the need for open ports and reduces attack surface.
Session Manager operates over WebSocket connections using AWS Identity and Access Management (IAM) policies for authorization. You can start a session from any machine with AWS CLI or SDK access, provided you have the correct permissions.
When you run aws ssm start-session --target i-1234567890abcdef0, the AWS CLI sends a request to the Session Manager service. The service checks your IAM role permissions and then instructs the target EC2 instance to establish a connection back to the Session Manager endpoint.
The instance runs a daemon called the SSM Agent, which listens for incoming session requests. Once the agent receives the instruction, it opens a WebSocket tunnel to the Session Manager backend. All communication-including keystrokes, terminal output, and command execution-flows through this encrypted channel.
This architecture avoids the common risks of SSH: no password storage, no key rotation issues, and no exposure of ports to the internet. Even if a hacker compromises your workstation, they cannot access the instance unless they also compromise your IAM credentials.
To use ssm start session, you need:
ssm:session-manager:enabled=true or the instance's IAM role granting ssm:StartSession permissionFor example, assign the following policy to an IAM user or role:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ssm:StartSession"
],
"Resource": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0"
}
]
}
If the instance lacks proper IAM roles or the SSM Agent isn't running, the session fails with error InvalidInstanceId or SessionManagerConnectionFailed.
System administrators use ssm start session to troubleshoot servers during outages, especially when network firewalls block SSH. For example, during a production outage in a VPC with no internet gateway, engineers connected via SSM to diagnose a failed database process.
DevOps teams deploy scripts remotely using ssm start-session to patch systems or verify configurations. A team at a financial firm automated patching across 150 instances using a single script executed via Session Manager, reducing manual effort by 80%.
Security auditors use the feature to inspect systems without leaving audit trails. Session Manager logs all activity to CloudTrail, including who started the session, what commands were run, and when it ended. These logs are immutable and stored for 90 days by default.
There are two primary modes for starting sessions:
| Mode | Description | Use Case |
|---|---|---|
| Interactive | Full terminal access with keyboard input and real-time output | Debugging applications, editing config files |
| Non-interactive | Run a single command and exit; useful for automation | Running health checks, fetching system metrics |
Use the --document-name flag to specify a custom document. For example:
aws ssm start-session \
--target i-1234567890abcdef0 \
--document-name "AWS-RunShellScript" \
--parameters 'commands=["df -h", "uptime"]'
This runs two commands and exits immediately. Output appears in the terminal, useful for scripted monitoring.
ssm start session is often mistaken for SSH or bastion hosts. Unlike SSH, it doesn't require public IPs or port forwarding. It also differs from bastion hosts because it doesn't require maintaining a separate jump server.
Another misconception is that Session Manager requires a dedicated network interface. It does not. The SSM Agent uses existing outbound connectivity, typically over port 443, which is rarely blocked by corporate firewalls.
Some users assume that because it's web-based, it's less secure. The opposite is true: all data is encrypted in transit using TLS 1.2+, and sessions are terminated automatically after 1 hour of inactivity. You can set a custom timeout using the --duration parameter.
I once debugged a memory leak on a production application hosted in a private subnet. The server had no public IP, and the firewall blocked all inbound traffic. Using ssm start session, I accessed the instance in under 10 seconds. I ran top -p $(pgrep java) and confirmed high memory usage. After identifying the issue, I applied a fix and verified it worked-all without touching the network configuration.
While both tools enable remote access, Session Manager is designed for operational tasks and automation. Instance Connect is optimized for interactive login and integrates with browser-based terminals.
For example, if you're running a long-lived debugging session, use ssm start session. If you're connecting from a web browser to quickly check logs, use Instance Connect. They share the same underlying infrastructure but serve different workflows.
Always restrict access using IAM policies. Avoid granting ssm:StartSession to broad groups. Instead, use conditions based on instance tags or resource ARNs.
Enable CloudTrail logging for all SSM actions. Audit trails show exactly which user accessed which instance and what commands were executed. This meets compliance requirements for PCI DSS, HIPAA, and SOC 2.
Use session duration limits. Set --duration 3600 to cap sessions at one hour. This prevents accidental long-running sessions and reduces risk of credential misuse.
Finally, test access in staging environments before deploying to production. Misconfigured IAM roles are the most common cause of session failures.