AWS 066: Key pairs and Session Manager access
The problem
A team uses Key pairs and Session Manager access as a label or Console setting without proving the identity, scope, behavior, failure boundary, cost, or operational result. The configuration appears complete but the real requirement remains untested.
Final outcome
The learner will inspect, explain, test, and document Key pairs and Session Manager access. The submission must connect the Console and CLI view to the same AWS control, state what the evidence proves, diagnose one likely failure, and make a requirement-based architecture decision.
Learning outcomes
You will be able to:
- explain a key pair proves ssh or windows access;
- explain rsa and ed25519 support differs;
- explain security groups must permit direct access;
- explain session manager uses systems manager control channels;
- explain session activity can be governed and logged;
- distinguish successful configuration from successful workload behavior;
- preserve redacted evidence and complete the stated cleanup or retention decision.
Mental model
requirement
-> identity and permission
-> account, Region, and resource scope
-> configuration or request
-> observable state
-> workload result
-> failure evidence
-> cleanup or controlled retention
Never begin with a create button or a copied command. Start with the result that must be proven and the boundary that must remain protected.
Core facts
| Concept | What it means in practice |
|---|---|
| A key pair proves SSH or Windows access | EC2 stores the public key and the customer keeps the private key. AWS does not retain a downloadable copy of a generated private key after creation. |
| RSA and ED25519 support differs | Linux instances support RSA and ED25519 key pairs. Windows password retrieval supports RSA; ED25519 is not supported for Windows instances. |
| Security groups must permit direct access | SSH or RDP also needs routing, a reachable address or private network, host service, correct user, and restrictive inbound rules. A key pair alone opens no network path. |
| Session Manager uses Systems Manager control channels | It can provide shell access without inbound ports, bastion hosts, or public IPs when the instance is managed by SSM with an IAM role, agent, and endpoint connectivity. |
| Session activity can be governed and logged | IAM controls who starts sessions. Configure logging, encryption, session preferences, and shell restrictions according to the selected session type and audit requirements. |
| EC2 Instance Connect is another short-lived path | For supported configurations it pushes a temporary public key or uses an Instance Connect Endpoint, avoiding permanent shared keys while still relying on operating-system SSH controls. |
How to reason about it
Prefer federated operator identity plus Session Manager for routine administration. Keep an emergency path tested, restrict ssm:StartSession by instance tags and session documents, log commands where supported, patch the SSM Agent, and remember that tunnel and port-forwarding session contents cannot be logged like interactive shell commands.
Use the following decision table as a starting point, then change the answer when the scenario changes.
| Requirement | Preferred direction | Why |
|---|---|---|
| Private fleet needs audited shell access | Session Manager | No inbound management port or per-instance public address is required. |
| Temporary SSH is required for a supported instance | EC2 Instance Connect or its endpoint | Short-lived key delivery reduces permanent-key distribution. |
| Windows launch requires password decryption | RSA key pair | The Windows workflow does not support ED25519 keys. |
| Lost private key on an existing server | Use Session Manager or documented recovery | AWS cannot redownload the original private key. |
Prerequisites, permissions, Region, and cost
Run this lesson as the approved non-root course identity. Begin with aws sts get-caller-identity, confirm the private account record, and set the fixed project Region before any regional query. IAM resources are global within an account, while STS endpoints and the services reached by an identity can be regional.
Use only the read or change actions required for this lesson. An AccessDenied result is evidence to analyse, not permission to switch to root or attach AdministratorAccess. Record the action, resource, principal type, request context, and smallest justified correction.
The listed cost tier is T0 - no resource creation. Free Tier eligibility and credits are account-specific. Before a mutating lab, identify every resource that can charge, estimate its duration, start a timer, and write the reverse cleanup order. A budget reports cost after billing data arrives and is not a real-time stop control.
AWS Management Console method
- Open Systems Manager Fleet Manager and confirm that the instance appears as a managed node with an online agent.
- Open Session Manager, choose Start session, select an authorized learning instance, and start a shell without opening inbound SSH or RDP.
- Inspect Session Manager Preferences for logging and encryption, then close the session and verify its audit record.
For every step record the service page, selected account and Region, exact object, visible state, and why that state matters. A Console label or green status is not enough unless it is tied to the final workload outcome.
AWS CLI or API evidence
Check whether the instance is registered and online as a Systems Manager managed node.
aws ssm describe-instance-information --filters Key=InstanceIds,Values=i-0123456789abcdef0 --query 'InstanceInformationList[0].{Ping:PingStatus,Agent:AgentVersion,Platform:PlatformName,Profile:IamRole}'
No online record points to agent, IAM instance profile, endpoint or internet connectivity, Region, registration, or service configuration. It is not solved by opening SSH.
Before running the command, replace every placeholder, explain each option, and decide whether the operation is read-only or mutating. Capture the exit code immediately. Redact account IDs, ARNs, public addresses, request identifiers, and personal data before sharing.
The CLI and Console are clients of AWS APIs. Matching state across them increases confidence, but neither substitutes for data-plane or application verification.
Practical work
Create p04-access-plan.md. Compare SSH key-pair administration with Session Manager. For the approved path, prove the future instance needs the AmazonSSMManagedInstanceCore permissions through nw-p04-ec2-ssm, a running SSM Agent, DNS, outbound HTTPS, matching Region, and operator session permission. Record why no key pair and no inbound TCP 22 are selected.
The evidence package must include:
- non-root principal type, account verified privately, and Region;
- exact intended and observed state;
- one Console observation and the matching CLI or API result;
- one successful result and one denied, failed, or counterexample result;
- what each result does not prove;
- cost state and elapsed lab time;
- cleanup evidence or a named retained-state owner and next lesson.
Verification standard
Use three levels of proof:
- Control plane: the object or policy exists with the intended configuration.
- Data plane or behavior: the request, packet, session, storage path, or application does what the requirement states.
- Operations: monitoring, failure diagnosis, cost, ownership, and cleanup are known.
A control-plane response can precede final readiness. Use waiters or state polling where supported, then test the actual behavior. If a request times out, do not assume it failed. Inspect state and use documented idempotency before retrying a mutation.
Troubleshooting method
| Symptom | Evidence first | Smallest safe response |
|---|---|---|
| command cannot authenticate | credential source, expiry, caller preflight | restore approved temporary login |
| access is denied | action, resource, principal, all policy layers | correct only the missing or conflicting control |
| object appears missing | account, Region, filters, pagination, permission | align scope before creating anything |
| configured state exists but behavior fails | route, identity, dependency, logs, service state | test the next boundary in the path |
| cleanup is blocked | dependency inventory and owning service | remove dependants in reviewed reverse order |
Keep the original symptom and timestamp. State one hypothesis, make one reversible change, repeat the original test, and record rollback. Never open a management port to the world, expose credentials, disable TLS verification, format an unknown disk, or add broad permissions as a generic fix.
Architecture and certification decisions
Professional-level questions provide competing valid features. Identify the requirement that decides between them: human or workload identity, same-account or cross-account access, regional or zonal scope, stateful or stateless filtering, durable or ephemeral data, latency, RTO/RPO, cost, or operational ownership.
Explain why the selected option fits and why each plausible alternative fails one stated requirement. Do not rely on feature memorization or reproduce protected certification questions.
Knowledge check
- Can AWS recover a generated key-pair private key after download?
Expected direction: No. Store it securely or use another controlled access method.
- Does Session Manager require inbound TCP 22?
Expected direction: No. The managed node initiates service connections.
- Can ED25519 be used for the EC2 Windows password workflow?
Expected direction: No. Use RSA for Windows.
- Does an online SSM agent automatically let every user start a session?
Expected direction: No. IAM and session-document permissions must authorize the operator.
Cost, cleanup, and retained state
Retain only the state explicitly required by the next P04 lesson and record it in the private resource ledger.
Cleanup evidence includes the final state query, not only a successful delete response. Search related resources, other Regions used by the lab, retained storage, public IPv4 addresses, logging destinations, and service-managed dependencies. Schedule a later billing review because cost data can lag.
Completion gate
Pass when the practical artifact explains the real problem, matches Console and CLI evidence, answers every knowledge check, diagnoses one failure without broadening access, records cost, and proves cleanup or approved retention. The learner must defend one decision orally and name the requirement that would change it.