Pcornel
Browse topics
Options
Recent
Favorites
Security · Technical reference

Private Keys

Direct answer

Private keys used for TLS, SSH and signing are secrets of the highest value. Store them encrypted with restrictive permissions, ideally in an HSM, TPM or vault, and rotate them on exposure.

When to use this

Use this when protecting private keys for TLS, SSH and signing.

First 30 seconds

1. Private keys (TLS, SSH, signing) must be protected.

2. File permission 600, encrypted at rest.

3. HSM/KMS for high value.

4. Rotate and revoke if exposed.

5. Inventory.

Operational verification

key → protected storage → use

Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Common mistakes
  • Exportable private keys in Windows stores for keys that should never leave the server.
  • Keys in container images.
  • No inventory of where each key is used.
  • Backups of HSM keys missing, so HSM failure loses keys.
Platform / version applicability
Cryptography, PKI and secrets
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCryptography, PKI and secrets
Scope / prerequisiteUse this when protecting private keys for TLS, SSH and signing.
What next?2 suggested next steps
Evidence1
On this pageJump to a specific section
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Encrypted at rest with tight permissions.
  • HSM or TPM for high value keys.
  • Revoke and replace on exposure.
Key checks
  • find / -name '*.pem' -o -name '*.key' 2>/dev/null | xargs ls -l — key file permissions
  • HSM/KMS usage — non-exportable keys
  • gitleaks detect — keys in repos
ReferenceWhy it matters1 section · depth on demand

Protecting private keys

  • Generate where used; prefer non-exportable storage (HSM, TPM, cloud KMS, YubiKey).
  • File permissions 600; passphrase-protected if on disk.
  • Separate keys per purpose (TLS, signing, SSH) and per system.
  • Short-lived certificates (ACME, SSH certificates) reduce the impact of a stolen key.
  • Revoke and replace immediately on exposure.
ReferenceImportant terms & boundaries2 sections · depth on demand

Storage options

OptionProtection
File with chmod 600Basic, readable by root
Encrypted with passphraseProtects at rest
OS key store (Windows CNG, macOS Keychain)Non-exportable keys possible
TPM / Secure EnclaveBound to the device
HSM / cloud KMSNever leaves the device; usage audited
Hardware token (YubiKey)Personal SSH/PGP keys

In depth

Private keys are the secret half of asymmetric key pairs used for TLS servers, SSH, code signing, document signing and certificate authorities. Anyone with the private key can impersonate its owner, so key protection is fundamental to PKI.

KeyProtection
CA keysHSM, offline root CA
Code signing keysHSM or cloud KMS; signing service, never on developer laptops
TLS server keysFile permissions (0600), per-server keys, automated renewal
SSH user keysPassphrase or hardware key (FIDO2), agent forwarding avoided

If a private key is exposed, revoke the associated certificate, replace the key (not just the certificate) and investigate where the key was used.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCryptography, PKI and secrets current

Authoritative/upstream documentation reviewed for bounded claims in Secrets Management → Private Keys. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html · confidence 94%
Confirmation

Confirm action

Continue?