What is an SSH Key Pair?
An SSH Key Pair consists of two cryptographically linked keys used by the Secure Shell (SSH) protocol to authenticate remote logins and secure server communication. SSH key authentication relies on public-key cryptography (asymmetric encryption), eliminating the security risks associated with traditional password-based authentication.
SSH Public Key (`id_ed25519.pub`)
The public key is shared freely and installed on target servers (typically appended to ~/.ssh/authorized_keys). Anyone with your public key can encrypt data that only your matching private key can decrypt.
- Safe to share publicly and place on servers
- Contains public parameters and optional user comment
- Usually stored as a single-line ASCII text file
SSH Private Key (`id_ed25519`)
The private key must be kept strictly secret on your local computer. It signs authentication challenges issued by the server to prove your identity.
- Never share or upload private keys
- Should be protected by a strong passphrase
- Formatted as OpenSSH or PEM block structure
Comparison of SSH Key Algorithms
Ed25519
Twisted Edwards curve (256-bit). High speed, small signature size, constant-time execution resistant to side-channel attacks.
RSA (2048/4096)
Widely compatible integer factorization algorithm. Use 4096-bit for long-term security; avoid < 2048-bit sizes.
ECDSA
NIST curves (P-256, P-384, P-521). Compact key size with standardized elliptic curve parameters.
DSA
Legacy 1024-bit Digital Signature Algorithm. Disabled by default in OpenSSH 7.0+. Should be replaced immediately.
SSH Key Fingerprints Explained
An SSH Fingerprint is a short cryptographic hash of the public key wire representation. When connecting to an SSH server for the first time, your SSH client displays the server’s host key fingerprint to prevent Man-in-the-Middle (MitM) attacks.
SHA-256 (Default)
Base64 encoded 256-bit hash (e.g., SHA256:4/x...). Standard format used in modern OpenSSH versions.
MD5 (Legacy)
Hexadecimal 128-bit hash (e.g., MD5:c1:b2:...). Used in older legacy SSH systems.
SSH Key Management Best Practices
- Use Ed25519 or RSA 4096 for new key generation.
- Always set a strong passphrase on private keys (
ssh-keygen -p). - Never store or upload private keys to unverified web servers or online repositories.
- Regularly audit
~/.ssh/authorized_keysacross all cloud servers.