Using AWS KMS for secure SSH credential management
Storing SSH credentials safely is harder than it looks. Here is how AWS KMS fits into a modern SSH access flow — the good, the friction, and the pitfalls.
AWS KMS is an excellent piece of infrastructure. It is also frequently misused in SSH credential flows in ways that make incident response harder, not easier. Here’s how we think about it.
What KMS actually gives you
KMS stores a master key you never see, encrypts/decrypts payloads under it, and logs every use. For SSH, the typical pattern is:
- Generate an SSH keypair in your CI or control plane.
- Encrypt the private key with KMS.
- Store the ciphertext in S3, Secrets Manager, or a database.
- At use time, decrypt the ciphertext with a KMS call.
This gives you: audit logs of who touched the key, centralized access control via IAM, and separation between “can see the encrypted blob” and “can decrypt it.”
Where it gets misused
Long-lived decrypted keys. Teams decrypt the key at app startup and hold it in memory for the process lifetime. If the app is compromised, so is the key. Decrypt per-use and zeroize.
Over-broad KMS grants. A single IAM role that can decrypt every SSH key in the org is the opposite of least privilege. Scope decrypt permissions per environment, and use KMS grants instead of IAM policies for fine-grained control.
Missing audit trails. CloudTrail logs every KMS Decrypt call, but only if you have a multi-region trail enabled. Many teams find this out during an incident.
The pattern that works
For SSH specifically, we use KMS to wrap session-scoped SSH certificates, not long-lived keys. The flow:
- Operator authenticates via SSO.
- Control plane mints a short-lived SSH cert signed by a CA private key.
- The CA private key lives in KMS; every signing operation is a
Signcall — the key itself never exits KMS. - The cert is delivered to the agent for the specific session.
- Cert expires in 15 minutes; no rotation needed.
Two properties fall out of this:
- The most sensitive secret (the CA private key) never leaves KMS.
- Every operator session shows up as a KMS
Signevent you can correlate to an operator identity.
When not to use KMS
If you don’t need audit or cross-account key sharing, a local KMS is overkill. For a single-region, single-account setup, Secrets Manager with rotation is simpler and serves most teams.
KMS is a force multiplier when you already have a multi-account, audit-heavy environment. It’s not a magic box that makes SSH safer — it’s a durable place to put the single keystone secret in a credential-minting flow.
Try it yourself
LynxTrac is free forever for 2 servers — no credit card, no sales call. Start in under 2 minutes →
Related posts
First 30 minutes of an IT incident: what great teams do
The first 30 minutes make or break MTTR. Here are the concrete moves high-performing teams make — and the anti-patterns we see everywhere else.
Incident response without VPN access: a practical guide
Your pager just went off and the VPN is down. Here is a practical runbook for getting to the affected system, gathering context, and fixing it without tunnels.
When to use browser-based vs thick-client remote desktop
Browser remote desktop is not always the right call. Here is the decision grid we use to pick between web and native clients for different workloads.