# Operating EC2 with Systems Manager

> Access, patch and configure fleets of instances without SSH keys or open ports using AWS Systems Manager. Free notes, key concepts, resources and a mini...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-operations
Last updated: 2026-11-28

Access, patch and configure fleets of instances without SSH keys or open ports using AWS Systems Manager.

Intermediate · about 3 hours · difficulty 2/5

Learn first: [EC2 Instances, AMIs and Pricing Options](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals), [STS, Assume Role and Federation](https://www.internhack.in/roadmaps/tracks/cloud-engineer/iam-roles-federation)

Opening port 22 to the world and sharing .pem files on WhatsApp is how many first projects start. Production teams use **AWS Systems Manager (SSM)** instead.

### Session Manager

- Shell access from the console or CLI with **no inbound ports**, no bastion host and no SSH keys.
- Access is controlled by IAM and every session can be logged to S3 or CloudWatch.
- Requirements: the SSM Agent (pre-installed on Amazon Linux and Ubuntu AMIs), an instance role with the AmazonSSMManagedInstanceCore policy, and outbound access to SSM (NAT or interface endpoints).

### Other SSM capabilities

- **Run Command**: run a script across many instances at once.
- **Patch Manager**: schedule OS patching with maintenance windows.
- **Parameter Store**: store configuration and secure strings (covered again in the security section).
- **Inventory** and **State Manager** to track and enforce configuration.

### Instance metadata

Instances can query http://169.254.169.254 for their ID, region and role credentials. Require **IMDSv2** (session tokens) to block SSRF-based credential theft.

Azure Bastion with Azure Arc and GCP OS Login with IAP tunnelling solve the same problem on other clouds.

### Pitfalls

- Instance role missing, so the instance never appears in Fleet Manager.
- Private subnets with no NAT and no SSM endpoints, so the agent cannot connect.

You are ready to move on when you can connect to a private instance with Session Manager, with no SSH key and no open inbound ports.

## Key concepts

- **Session Manager**
- **SSM Agent and instance role**
- **Run Command**
- **Patch Manager**
- **IMDSv2**
- **EC2 Instance Connect**

## Mini project

Launch a free-tier instance with no key pair and a security group with zero inbound rules. Attach an SSM role, connect with Session Manager, and use Run Command to install htop. Log sessions to a CloudWatch log group. Terminate the instance and delete the log group afterwards.

## Check yourself

List the three things an EC2 instance needs before it shows up as a managed node in Systems Manager.

## Free resources

- [AWS Systems Manager documentation](https://docs.aws.amazon.com/systems-manager/) (AWS)
- [Use IMDSv2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html) (AWS)

Previous: [EC2 Instances, AMIs and Pricing Options](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals) · Next: [Elastic Load Balancing: ALB and NLB](https://www.internhack.in/roadmaps/tracks/cloud-engineer/load-balancers)

## More in Compute: EC2, Auto Scaling and Load Balancing

- [EC2 Instances, AMIs and Pricing Options](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-fundamentals)
- [Operating EC2 with Systems Manager](https://www.internhack.in/roadmaps/tracks/cloud-engineer/ec2-operations)
- [Elastic Load Balancing: ALB and NLB](https://www.internhack.in/roadmaps/tracks/cloud-engineer/load-balancers)
- [Auto Scaling Groups and Launch Templates](https://www.internhack.in/roadmaps/tracks/cloud-engineer/auto-scaling)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
