Use this when protecting or responding to exposure of a private key.
Private Key
A private key is the secret half of a key pair, used to decrypt and sign. Protect it with file permissions, passphrases, HSMs or TPMs, and revoke the certificate immediately if it is exposed.
1. Private keys must stay secret.
2. Restrict file permissions; encrypt at rest.
3. Prefer HSM/TPM/KMS (non-exportable).
4. Never commit to repositories.
5. Revoke and rotate if exposed.
private key → protected storage → used for sign/decrypt
Context & applicabilityCommon mistakes · platform/version boundaries
- Private keys in Git repositories or container images.
- World-readable key files (
chmod 600on Linux). - Unencrypted keys on laptops; use a passphrase or hardware token.
- Same key reused on many servers, so one compromise affects all.
- No plan for revocation and re-issuing if a key leaks.
Operational reference
Fast context before you go deeper.
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.
- Whoever has the private key can impersonate you.
- Store it encrypted or in an HSM/TPM.
- Revoke and reissue on exposure.
ls -l <key.pem>— permissions (600)- Key stored in HSM/TPM/KMS — non-exportable
grep -r 'BEGIN .*PRIVATE KEY' <repo>— leaked keys in code
ReferenceWhy it matters1 section · depth on demand
Protecting private keys
- File permissions
600, owned by the service account. - Passphrase-encrypted (SSH, PEM) or in hardware: TPM, HSM, smart card, cloud KMS (non-exportable).
- Never in Git, tickets, chat or container images; scan repos for leaked keys.
- Revoke and replace immediately if exposed (certificate revocation, remove from authorized_keys).
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
A private key is the secret half of an asymmetric key pair: it creates signatures and decrypts or derives keys that the public key enables. Whoever holds it can act as its owner, so protecting it is the core of asymmetric security.
| Storage | Protection level |
|---|---|
| HSM / cloud KMS | Key never leaves hardware |
| TPM / secure enclave / smart card / FIDO2 key | Non-exportable, device-bound |
| Encrypted file with passphrase | Moderate |
| Plain file | Only acceptable with strict permissions on servers (0600) |
chmod 600 /etc/ssl/private/server.key
ssh-keygen -p -f ~/.ssh/id_ed25519 # add or change passphrase
If a private key is exposed, revoke related certificates, replace the key pair and investigate its use.
ReferenceConfiguration & state1 section · depth on demand
Commands
chmod 600 ~/.ssh/id_ed25519
ssh-keygen -p -f ~/.ssh/id_ed25519 # add/change passphrase
openssl pkey -in server.key -aes256 -out server-enc.key
ssh-keygen -t ed25519-sk # key on a FIDO2 hardware token
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Asymmetric Cryptography → Private Key. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/fips/186-5/final · confidence 94%