Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Private Keys

Direct answer

A private key is the secret half of a key pair used by a TLS service or SSH; whoever has it can impersonate the service.

When to use this

Use it when installing, protecting or matching keys to certificates.

First 30 seconds

1. ls -l <key> — 600/640 and correct owner?

2. Matches the cert? openssl x509 -noout -pubkey -in <cert> | sha256sum vs openssl pkey -pubout -in <key> | sha256sum.

3. Type and size: openssl pkey -in <key> -noout -text | head -1.

4. Encrypted keys need a passphrase at service start — usually unencrypted with strict permissions.

5. Rotate if exposed.

Operational verification

key generated → stored with strict permissions → paired with its certificate → used by the service

Evidence · next step

For Certificates & TLS → Private Keys, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Private Keys. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
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.

Platformlinux
Scope / prerequisiteUse it when installing, protecting or matching keys to certificates.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

key generation/import → protected storage/ownership → service read access → public-key match to certificate → TLS/signature use → rotation/revocation lifecycle

Healthy evidence: key material is protected, owned/readable only by intended principals, cryptographically matches the certificate and service restart/reload uses it successfully

Step 2 Verification and output interpretation Verify boundary

Verification chain. key generation/import → protected storage/ownership → service read access → public-key match to certificate → TLS/signature use → rotation/revocation lifecycle

Step 3 Commands Verify boundary
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out key.pem
chmod 600 key.pem
openssl pkey -in key.pem -noout -text | head
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: world/group exposure, stale copies/backups, wrong owner, key/cert mismatch, unencrypted export, service cannot read key or rotation leaves old key active

Step 5 Common mistakes Narrow the fault
  • Private keys committed to Git or world-readable.
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

Permissions 600 (or 640 with a service group), owned by root or the service. Do not email or commit keys. Check the key matches the certificate by comparing public keys. Prefer EC (P-256) or RSA ≥ 2048.

Key checks
  • openssl x509 -in <cert> -noout -subject -issuer -dates -ext subjectAltName — certificate details
  • openssl s_client -connect <host>:443 -servername <name> </dev/null — live chain and verification
  • openssl verify -CAfile <ca> -untrusted <chain> <cert> — chain validation
  • trust list | head / ls /etc/ssl/certs — system trust store
ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

Private-key handling is confirmed when custody and effective service access are least-privilege, the key matches the intended certificate and rotation/recovery are validated without exposing secret material.

In depth

Private keys: generation and protection

The private key is the secret part of a certificate pair, and protecting it matters more than anything else in TLS. The openssl-genpkey(1) manual page documents key generation:

  • Algorithms include RSA, RSA-PSS, EC, Ed25519 and Ed448.
  • RSA keys default to 2048 bits (rsa_keygen_bits), and EC keys take a curve such as P-256 or P-384 (ec_paramgen_curve).
  • A cipher option encrypts the key with a passphrase (-pass).
  • The output is PEM by default.

Choosing a key type

TypeCommandNotes
ECDSA P-256openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out server.keySmall, fast; widely supported
RSA 3072openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out server.keyMaximum compatibility
Ed25519openssl genpkey -algorithm ED25519 -out signing.keyGood for signing; limited support in public web PKI

Protecting keys

PracticeDetail
File permissions600 (or 640 with the service's group), owned by root
Location/etc/ssl/private (mode 710 or 700), or the application's protected directory
Never in Git, tickets or chatUse a secrets manager or configuration management with encryption
PassphrasesFor keys used interactively; services usually need unencrypted keys or an HSM/TPM
One key per serviceA compromise affects only one service
Rotate on suspicionA new key and a new certificate; revoke the old one

After a key compromise

A certificate stays valid until it expires, even if its key has been stolen. The fix is to revoke the certificate with the CA, and to issue a new one with a new key. Reusing the same key with a new certificate doesn't help.

host$ sudo install -d -m 0710 -g ssl-cert /etc/ssl/private
host$ sudo openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out /etc/ssl/private/www.key
host$ sudo chmod 640 /etc/ssl/private/www.key && sudo chgrp ssl-cert /etc/ssl/private/www.key
host$ sudo openssl pkey -in /etc/ssl/private/www.key -noout -text | head -2
Private-Key: (256 bit)
priv:
host$ sudo find / -xdev \( -name '*.key' -o -name '*.pem' \) -perm /004 2>/dev/null | xargs -r grep -l "PRIVATE KEY"
/opt/legacy/conf/server.pem
host$ git -C /srv/repo log --all -p | grep -c "BEGIN .*PRIVATE KEY"

Reading the search

The find command lists world-readable files that contain a private key. One legacy application keeps its key readable by every user. That's a finding: tighten its permissions, and consider the key exposed if untrusted users could log in. The last line checks a Git history for keys that were ever committed.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Private Keys is part of Certificates & TLS → Private Keys. Private Keys are secret cryptographic material used to show possession for TLS and signing; Linux operations must protect generation, storage, permissions, ownership, encryption and service access while proving the key matches its certificate.

Topic-specific state model. Private Keys are secret cryptographic material used to show possession for TLS and signing; Linux operations must protect generation, storage, permissions, ownership, encryption and service access while proving the key matches its certificate.

Interpretation rule. - A private key file with mode 0600 ≠ safe key custody if ownership, backups, copies or process exposure are wrong.

  • A certificate and key both parse ≠ they form a matching pair.

Quick reference

Private key handling:

openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out key.pem
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out key.pem
chmod 600 key.pem; chown root:root key.pem
openssl pkey -in key.pem -noout -text | head -3
# key matches certificate?
openssl x509 -in cert.pem -noout -pubkey | sha256sum
openssl pkey -in key.pem -pubout | sha256sum

Never email or commit private keys; store them in a secret manager or HSM, use separate keys per service, and rotate on suspected exposure (and revoke the certificate).

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Private-key handling is confirmed when custody and effective service access are least-privilege, the key matches the intended certificate and rotation/recovery are validated without exposing secret material.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Private Keys owns Linux key material handling; Secrets/Security owns broader automation secret lifecycle.

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 doclinux current

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

Basis: https://docs.openssl.org/ · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
private key linuxtls private keyopenssl private key
Embedded reference data

Quick lookup tables

Private Keys operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Private Keys.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective statePrivate Keys are secret cryptographic material used to prove possession for TLS and signing; Linux operations must protect generation, storage, permissions, ownership, encryption and service access while proving the key matches its certificate.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainkey generation/import → protected storage/ownership → service read access → public-key match to certificate → TLS/signature use → rotation/revocation lifecycleTrace requested/configured state through effective state to the observed workload result.
Failure boundaryPrivate-key handling is proven when custody and effective service access are least-privilege, the key matches the intended certificate and rotation/recovery are validated without exposing secret material.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux security/trust evidence can establish this proof path: key generation/import → protected storage/ownership → service read access → public-key match to certificate → TLS/signature use → rotation/revocation lifecycleUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. Private-key handling is proven when custody and effective service access are least-privilege, the key matches the intended certificate and rotation/recovery are validated without exposing secret material.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks.Continue to the next unresolved boundary while preserving the original test condition.

Private Keys · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryPrivate Keys
Topic pathCertificates & TLS → Private Keys
Runtime statePrivate Keys are secret cryptographic material used to prove possession for TLS and signing; Linux operations must protect generation, storage, permissions, ownership, encryption and service access while proving the key matches its certificate.
Fast checks- Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Private Keys. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check.
Verification chainkey generation/import → protected storage/ownership → service read access → public-key match to certificate → TLS/signature use → rotation/revocation lifecycle Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryPrivate-key handling is proven when custody and effective service access are least-privilege, the key matches the intended certificate and rotation/recovery are validated without exposing secret material. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?