Use this when generating and handling key pairs.
Key Pair
A key pair is a mathematically linked public and private key generated together, for example with openssl genpkey or ssh-keygen. What one key does, only the other can undo or verify.
1. A key pair = private + public key.
2. Generate on the system that uses it (or in HSM).
3. Strong RNG.
4. Document purpose and owner.
5. Rotate periodically.
CSPRNG → private key → derived public key
Context & applicabilityCommon mistakes · platform/version boundaries
- Generating keys on machines with little entropy (fresh VMs, embedded devices) — keys may repeat.
- Generating server keys on a laptop and copying them around.
- Using old defaults (
ssh-keygen -t rsa1024 on very old systems). - Storing the private key in the same location as the CSR sent to the CA.
Operational reference
Fast context before you go deeper.
openssl x509 -in server.crt -pubkey -noout | openssl sha256Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checking a key pair matches Verify boundary
openssl pkey -in server.key -pubout | openssl sha256
openssl x509 -in server.crt -pubkey -noout | openssl sha256
openssl req -in server.csr -pubkey -noout | openssl sha256
All three hashes must be identical; otherwise the certificate does not belong to the key.
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.
- Generate keys on the system that will use them.
- Protect the private key.
- Back up keys that protect data.
ssh-keygen -t ed25519 -C <comment>— generate SSH key pairopenssl genpkey -algorithm ED25519 -out key.pem— generate- Key generation location — on target system/HSM
ReferenceWhy it matters1 section · depth on demand
Generating key pairs
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out rsa.key
openssl genpkey -algorithm ED25519 -out ed.key
openssl pkey -in ed.key -pubout -out ed.pub
ssh-keygen -t ed25519 -C "admin@example.com"
Documented example, not captured output. Generate keys where they will be used (or in an HSM) rather than copying private keys between systems.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
A key pair is the matching public and private keys generated together for asymmetric cryptography. Generating key pairs correctly — strong algorithm, adequate size, good randomness, generated where the private key will live — is the first step of any certificate, SSH or signing setup.
ssh-keygen -t ed25519 -C "admin@jump01"
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out server.key
openssl req -new -key server.key -subj "/CN=netbox.example.com" -addext "subjectAltName=DNS:netbox.example.com" -out server.csr
| Use | Recommended algorithm |
|---|---|
| SSH | Ed25519 |
| TLS servers | ECDSA P-256 or RSA 2048/3072 |
| Long-term signing | RSA 3072+ or ECDSA P-384 |
Generate keys on the system that uses them (or in an HSM) and send only the CSR or public key elsewhere.
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 → Key Pair. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/fips/186-5/final · confidence 94%