AWS from zero · Part 2: Networking and compute · Lesson 11 of 38 · about 50 minutes

Systems Manager: servers without SSH

A server with no public address, no key pair, no internet route and not one inbound rule, and you still run commands on it, read its configuration from Parameter Store and open a shell on it. AWS Systems Manager turns the connection around: the server calls out to AWS, through three private endpoints. Plus the trap the lab walked into: a private server that says it's up to date without checking.

By the end you'll know

  • Why SSH (Secure Shell) and bastions are being replaced, and what replaces them
  • What a server needs before Systems Manager can reach it: an agent, a role and a way to AWS
  • What VPC endpoints are, and what they cost
  • How to run commands on servers with Run Command, and open a shell with Session Manager
  • How to keep configuration and secrets in Parameter Store
  • Why a server with no way out can't patch itself, and why it may not tell you

Before you start

  • You need: the juniper-rye profile from Lesson 4, signed in, and Lessons 8 to 10.
  • The script: ssm-lab.sh from the practice folder's lesson-11. Everything it creates is named jr-lesson11-*, or sits under /juniper-rye/ in Parameter Store, and its delete step removes it.
  • How the script talks to AWS: only through the AWS CLI. The few lines of Python in it just turn the CLI's JSON into readable tables and never connect to AWS; boto3, AWS's Python library, comes in Lesson 20.
  • The Session Manager plugin on your machine, for the interactive shell. The lesson installs it.
  • Where you run things: your own machine, labeled (Your machine), and, once, a shell on the server, labeled (On the server).
  • Every output below is from a real run on November 10, 2026.

The endpoints bill by the hour

Each of the lab's three VPC endpoints costs $0.01 an hour, and the server about $0.014. The lab takes about 30 minutes: a few cents from credits. Forgotten, the three endpoints alone are $21.90 a month. Run delete the same day and check every line shows 0.

The short version

  • Systems Manager reverses the connection. An agent on the server calls out to AWS over HTTPS (HTTP Secure), so the server needs no inbound rules at all.
  • It needs three things: the agent (already on Amazon Linux), an IAM role, and a way to reach AWS: the internet, or VPC endpoints.
  • Three tools do the work: Run Command runs commands on servers and keeps a record, Session Manager opens a shell, and Parameter Store holds configuration and secrets.
  • No SSH means no keys to lose, no port 22, and no bastion. Who may connect is decided by IAM, and every session can be logged.
  • A server with no way out can't patch itself, and dnf may report success anyway.

What this lesson costs

PartCost
Systems Manager: Run Command, Session Manager, standard parameters$0
The VPC, subnet, security groups and IAM role$0
Three interface VPC endpoints for about 30 minutes$0.03 an hour together
A t4g.micro and its disk, no public addressAbout $0.009 an hour
This lessonA few cents, from credits
If the endpoints were left running$21.90 a month

Why not SSH?

Lesson 10's server had no SSH, because nothing needed to log in. But sometimes someone does: to read a log, check a setting or fix something at 2 a.m. The old answer was SSH, and for private servers, a bastion in a public subnet to hop through. That means:

  • Keys to manage: who has one, who left the company with one, which servers trust which.
  • Port 22 open somewhere, usually on the bastion, and sometimes, by mistake, to 0.0.0.0/0 (Lesson 9).
  • A server to run just for getting in, with its own patches and its own public address.
  • Little record of what anyone did once they were in.

Systems Manager turns the connection around. A program on each server, the SSM Agent, calls out to AWS and asks, every so often, "anything for me?". You ask AWS to run a command or open a session, and AWS hands it to the agent on its next check. Nothing ever connects in to the server.

Both ends call out, and Systems Manager joins them. The lab builds exactly this.
SSHSSH through a bastionSession Manager
Inbound port on the server22, from your address22, from the bastionNone
Public address neededOn the serverOn the bastionNone
KeysOne per person, on every serverThe same, plus the bastion'sNone: IAM decides who may connect
Record of what was doneOnly what the server logsOnly what the servers logEvery session and command can be logged
Extra costNoneThe bastion serverNone, or endpoints in a private network

What a server needs

  1. The SSM Agent. It comes installed on Amazon Linux and AWS's other main images.
  2. An IAM role that lets the agent talk to Systems Manager. AWS's managed policy AmazonSSMManagedInstanceCore is the usual one.
  3. A way to reach AWS over HTTPS. Either the internet, through a public address or a NAT gateway, or VPC endpoints: private doors from inside the VPC straight to an AWS service, with no internet involved.

The lab takes the strictest path: a private subnet with no internet route at all, so the endpoints are the only way out.

Is it allowed, and what does it cost?

(Your machine)

BASH
cd ~/Apps/aws-practice/lesson-11
chmod +x ssm-lab.sh
./ssm-lab.sh fence

The first run found everything allowed, and one thing missing:

OUTPUT
== The Session Manager plugin, on your machine
  not installed: ./ssm-lab.sh session needs it (Lesson 11 shows how to install it)

Install the Session Manager plugin

The AWS CLI needs a small plugin to open interactive sessions. These are AWS's steps for a Mac with Apple silicon; AWS's documentation has the steps for Intel Macs, Windows and Linux.

(Your machine)

BASH
cd ~/Downloads
curl -o session-manager-plugin.pkg "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/mac_arm64/session-manager-plugin.pkg"
sudo installer -pkg session-manager-plugin.pkg -target /
sudo ln -s /usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/session-manager-plugin
session-manager-plugin --version
rm session-manager-plugin.pkg
OUTPUT
installer: Package name is session-manager-plugin
installer: Installing at base path /
installer: The install was successful.
1.2.896.0
CommandWhat it does
curl -o ...Downloads AWS's signed installer for Apple silicon
sudo installer ...Installs it; asks for your Mac's password
sudo ln -s ...Puts it on your command path, where the AWS CLI looks for it
session-manager-plugin --versionConfirms it's there

Then fence again:

OUTPUT
== Is this allowed in us-east-2? (dry runs: nothing is created)
  create a VPC endpoint                allowed (the made-up VPC was rejected, as expected)
  launch a t4g.micro server            allowed
  IAM roles                            allowed for this account (Lesson 3)
== What the endpoints cost, in us-east-2 (AWS Price List)
  each interface endpoint: $0.010 an hour, $7.30 a month, in one zone
  this lab needs 3:        $0.030 an hour, $21.90 a month
  data through them:       $0.010 per GB
  Systems Manager itself (Run Command, Session Manager, standard parameters): $0
== The Session Manager plugin, on your machine
  installed, version 1.2.896.0

Endpoints are priced per endpoint, per zone. Three endpoints in one zone are $21.90 a month; the same three in two zones, for high availability, are $43.80. That's more than a NAT gateway's $32.85, which is why many teams use a NAT gateway for general traffic and endpoints only where they add something: privacy, or traffic that would cost more through the NAT gateway.

Build a server nobody can reach

In the console: VPC > Endpoints > Create endpoint, once for each of the three services, with Enable DNS name ticked. IAM > Roles > Create role, for EC2, with AmazonSSMManagedInstanceCore. Systems Manager > Parameter Store > Create parameter.

(Your machine)

BASH
./ssm-lab.sh build
OUTPUT
== A private network: no internet gateway, no NAT gateway
  VPC 10.11.0.0/16, private subnet 10.11.1.0/24, no route out
  jr-lesson11-server-sg: no inbound rules
  jr-lesson11-endpoints-sg: HTTPS (443) from inside the VPC only
  endpoint for ssm: billing starts
  endpoint for ssmmessages: billing starts
  endpoint for ec2messages: billing starts
== A role the server can use to talk to Systems Manager
  role jr-lesson11-ssm-role, with the AWS managed policy AmazonSSMManagedInstanceCore
== Two parameters in Parameter Store
  /juniper-rye/opening-hours       String
  /juniper-rye/supplier-api-key    SecureString, encrypted (a made-up value)
== Waiting for the endpoints to be ready
  3 available
== Launching jr-lesson11-server: t4g.micro, no public address, no key pair (billing starts)
  running
== Give it 2 to 3 minutes to check in with Systems Manager, then run ./ssm-lab.sh show
PartWhat it's for
Endpoint for ssmThe agent registers, checks in, and reads parameters
Endpoint for ec2messagesThe agent collects Run Command jobs and sends back results
Endpoint for ssmmessagesCarries interactive Session Manager sessions
Private DNS on each endpointThe usual names, like ssm.us-east-2.amazonaws.com, resolve to the endpoint's private address, so the agent needs no special setup
jr-lesson11-endpoints-sgLets HTTPS reach the endpoints from inside the VPC. The endpoints need an inbound rule; the server doesn't.
The role, as an instance profileHow a server gets an IAM role. Its trust policy lets EC2 use it (Lesson 3).

Check: no way in

In the console: Systems Manager > Fleet Manager lists every server the agent has checked in from.

(Your machine)

BASH
./ssm-lab.sh show
OUTPUT
== Ways in from the internet
  public IP address:        none
  key pair:                 none
  inbound rules:            0
  internet gateways:        0
  routes:
    10.11.0.0/16       -> local
== Its endpoints, the only way it can reach AWS
  com.amazonaws.us-east-2.ssm        available  private DNS on
  com.amazonaws.us-east-2.ssmmessages available  private DNS on
  com.amazonaws.us-east-2.ec2messages available  private DNS on
== Has it checked in with Systems Manager?
  status: Online
  system: Amazon Linux 2023
  agent:  version 3.3.5700.0

Every way in is closed, and the server is Online anyway. The security group has no inbound rules, but its default outbound rule lets the agent call the endpoints, and a security group lets the replies back (stateful, Lesson 9).

Run Command

In the console: Systems Manager > Run Command > Run command, choose AWS-RunShellScript, type the commands, and pick the server.

(Your machine)

BASH
./ssm-lab.sh run
OUTPUT
== Running 6 commands on jr-lesson11-server with Run Command
  status: Success
== What the server printed
  host:          ip-10-11-1-252.us-east-2.compute.internal
  running as:    root
  uptime:        up 5 minutes
  internet:      not reachable (no route out)
  opening hours: 7 to 3, closed Mondays
  supplier key:  jr-mad... (21 characters, decrypted on the server)

== From your machine, the same parameter without decryption
  AQICAHiIa+K9asmWCqmecpZZlpT51MlYUpJqWJK5...
== Systems Manager's record of what was run
  10:29:02  AWS-RunShellScript  "Lesson 11: check the bakery server"  Success

The call behind it:

BASH
aws ssm send-command --instance-ids i-... --document-name AWS-RunShellScript \
  --comment "Lesson 11: check the bakery server" --parameters file:///tmp/jr11-cmds.json
PartWhat it does
--instance-idsWhich servers. It can also target by tag, so one command reaches every server tagged owner=juniper-rye.
--document-name AWS-RunShellScriptA document is a Systems Manager recipe; this one runs shell commands. Others patch servers or install software.
--commentA note that stays in the record
--parameters file://...The commands to run

What the server's answers show:

  • Run Command runs as root. Whoever can send commands can do anything on the server, so IAM permission to ssm:SendCommand is as powerful as a root password.
  • internet: not reachable. The endpoints reach Systems Manager, nothing else.
  • There's a record. Every command, who sent it and when, stays in Systems Manager's history, and CloudTrail records it too (Lesson 33).

Parameter Store

The server read the bakery's opening hours and a supplier's key from Parameter Store, Systems Manager's place for configuration. Lesson 6's review flagged storing secrets in code as a high risk; this is one of the safer places for them.

TypeStored asUse it for
StringPlain textSettings: opening hours, a feature switch, a server name
SecureStringEncrypted with a KMS (Key Management Service) keySecrets: API keys, passwords

The SecureString was decrypted on the server, which printed only its first 6 characters and its length. From your machine, without asking for decryption, it's AQICAHi..., the encrypted form. Standard parameters are free. For secrets that need rotating on a schedule, Lesson 34 uses Secrets Manager instead.

The convenient policy reads every parameter

AmazonSSMManagedInstanceCore lets a server read every parameter in the account, not just its own. That's fine for a lab and too broad for real work. Give each server's role its own policy that allows ssm:GetParameter on its own path only, such as /juniper-rye/*.

Session Manager

In the console: EC2 > Instances > pick the server > Connect > Session Manager > Connect, or Systems Manager > Session Manager > Start session. Both open the shell in a browser tab.

(Your machine)

BASH
./ssm-lab.sh session

The script runs aws ssm start-session --target i-.... Four lines were pasted in at once, so they show first, then their output. (On the server)

OUTPUT
Starting session with SessionId: <your-session>-s62tfdusbp3jvjllz3zyco6xrq
sh-5.2$ whoami
hostname
sudo dnf check-update --refresh >/dev/null 2>&1 && echo "updates: reachable" || echo "updates: not reachable"
exit
ssm-user
ip-10-11-1-252.us-east-2.compute.internal
updates: reachable
exit


Exiting session with sessionId: <your-session>-s62tfdusbp3jvjllz3zyco6xrq.

A real shell, with no SSH. Two things to notice:

  • You're ssm-user, not root. Session Manager creates this less powerful user; sudo lifts it when needed. The Linux track's Permissions and users lesson covers users, root and sudo.
  • updates: reachable. That can't be right: Run Command found no internet, and the only route is local. It also took over 10 minutes to print.

The server that said it was up to date

A second session, one line at a time, found out why. (On the server)

OUTPUT
sh-5.2$ curl -m 5 -sI https://cdn.amazonlinux.com | head -1 || echo "cdn: not reachable"
grep -h skip_if_unavailable /etc/dnf/dnf.conf /etc/yum.repos.d/*.repo
sudo timeout 60 dnf check-update --refresh 2>&1 | tail -4; echo "exit code: ${PIPESTATUS[0]}"
exit
skip_if_unavailable=True
exit code: 124
exit
  • curl printed nothing: the package servers can't be reached. (The || echo never fired because head succeeded; a pipe's result is its last command's.)
  • skip_if_unavailable=True: Amazon Linux tells dnf to skip package servers it can't reach. The Linux track's Installing software lesson covers dnf and package repositories.
  • exit code: 124: after 60 seconds, dnf was still retrying when timeout stopped it.

So in the first session, dnf spent ten minutes failing to reach every package server, skipped them all, and reported success using the old package list saved on the image. It checked nothing, and nothing said so.

A private server can't patch itself, and may not tell you

With no way out, a server can't download security updates, and dnf can skip the unreachable servers and report success. Give private servers a way to their package repositories: a NAT gateway (Lesson 8), or, for Amazon Linux, a gateway endpoint for S3, which is free and is where its repositories are served from. Then check that patching really happened, which is what Systems Manager's Patch Manager reports on.

Take it down

In the console: EC2 > Instances > Terminate instance; VPC > Endpoints > Actions > Delete VPC endpoints; Systems Manager > Parameter Store > Delete; IAM > Roles > Delete; then VPC > Your VPCs > Actions > Delete VPC.

(Your machine)

BASH
./ssm-lab.sh delete

The first run stopped partway:

OUTPUT
== Terminated jr-lesson11-server
== Deleted the endpoints. Their billing stops now.
== Deleted parameter /juniper-rye/opening-hours
== Deleted parameter /juniper-rye/supplier-api-key
== Deleted role jr-lesson11-ssm-role

aws: [ERROR]: An error occurred (DependencyViolation) when calling the DeleteSecurityGroup operation: resource sg-07bb58d7334800542 has a dependent object

aws: [ERROR]: An error occurred (DependencyViolation) when calling the DeleteSubnet operation: The subnet 'subnet-0f2bea7ba9c6a93b9' has dependencies and cannot be deleted.

aws: [ERROR]: An error occurred (DependencyViolation) when calling the DeleteVpc operation: The vpc 'vpc-0166865da6408c58f' has dependencies and cannot be deleted.
== Left over from this lab
  servers:            0
  endpoints:          0
  VPCs:               1
  parameters:         0
  IAM role:           0
== Things that bill by the hour, anywhere in us-east-2
  servers:            0
  VPC endpoints:      0
  NAT gateways:       0

Each interface endpoint is a network interface in your subnet, an address with the endpoints' security group attached. An endpoint reports "deleted" before its interfaces are gone, and while they're there, the security group, the subnet and the VPC can't be deleted. Nothing was billing, but the network was stuck. The script now waits for the interfaces first, and the second run finished:

OUTPUT
== Waiting for 3 network interfaces to be released
== Deleted jr-lesson11-vpc and everything in it
== Left over from this lab
  servers:            0
  endpoints:          0
  VPCs:               0
  parameters:         0
  IAM role:           0
== Things that bill by the hour, anywhere in us-east-2
  servers:            0
  VPC endpoints:      0
  NAT gateways:       0

In real systems

  • Session Manager replaces bastions in most teams that adopt it, and port 22 is closed everywhere. A rule (Lesson 36) can stop anyone opening it.
  • Sessions are logged to CloudWatch Logs or S3 (Lesson 32), so there's a record of every command typed, not just who connected.
  • IAM decides who may start a session, and on which servers, often by tag: developers on test servers, only the on-call team in production.
  • Run Command and State Manager configure whole fleets, and Patch Manager patches them on a schedule and reports which servers are behind.
  • Endpoints are shared. One set per VPC, per zone, serves every server in it, so the cost doesn't grow with the number of servers.

Spot the problem

Work out what's wrong before you read the explanation.

"It's in Fleet Manager, but it says Connection Lost." A team moves a server into a new private subnet with no NAT gateway, to make it more secure. They add the ssm endpoint, and the server's role has AmazonSSMManagedInstanceCore. Session Manager won't connect, and the server shows Connection Lost. What's missing? The other two endpoints, ec2messages and ssmmessages, and possibly HTTPS into the endpoints. With only ssm, the agent can register but can't collect commands or carry a session. The fix: add all three endpoints with private DNS on, and a security group on them allowing 443 from the VPC. Then check: does aws ssm describe-instance-information show the server as Online?

Keep this

RememberWhy
The agent calls out; nothing connects inNo inbound rules, no public address, no keys
Agent, role, a way to AWSThe three things a server needs
Private: ssm, ec2messages, ssmmessages endpoints$7.30 a month each, per zone
Run Command runs as rootGuard ssm:SendCommand like a root password
Session Manager runs as ssm-userA shell with no SSH, and a record
SecureString for secretsEncrypted with KMS; decrypted only where allowed
No way out means no patchesAnd dnf may report success anyway
Endpoints leave interfaces behind for a whileWait for them before deleting the VPC

Where you are now

The bakery has a server with no public address, no key, no internet route and no inbound rules, and you still ran commands on it, read its settings and a secret, and opened a shell, all through three private endpoints and an IAM role. You also caught a private server claiming to be up to date when it couldn't check. Lessons 1 to 11 have built up to one server, done properly. Next, Lesson 12 puts several of them behind a load balancer, and lets AWS add and remove them as traffic changes.

Check yourself

  1. How does Systems Manager reach a server with no inbound rules?

  2. Which of these does a server not need for Systems Manager?

  3. In a private subnet with only the ssm endpoint, what fails?

  4. Who did Run Command's commands run as?

  5. The first session printed updates: reachable. What was really happening?

  6. Why did the first delete fail on the subnet and VPC?

Key terms

  • AWS Systems Manager: a set of AWS tools for running and managing servers.
  • SSM Agent: the program on a server that calls out to Systems Manager and does what it's asked.
  • Run Command: runs commands on one server or many, and keeps a record.
  • Session Manager: opens a shell on a server, with no SSH and no open port.
  • Session Manager plugin: the program the AWS CLI needs on your machine to open a session.
  • Document: a Systems Manager recipe, such as AWS-RunShellScript.
  • Parameter Store: Systems Manager's store for settings and secrets.
  • SecureString: a parameter encrypted with a KMS (Key Management Service) key.
  • VPC endpoint: a private way from a VPC to an AWS service, without the internet. Interface endpoints are billed by the hour.
  • Private DNS: makes an AWS service's usual name resolve to its endpoint inside the VPC.
  • Instance profile: how an EC2 server gets an IAM role.
  • Bastion: a server in a public subnet used only to reach private servers, which Session Manager replaces.
  • ssm-user: the less powerful user Session Manager logs you in as.

Go deeper