Knowledge Hub

ssh-keygen

Using the ssh-keygen command, users can create, view, and manage SSH keys.

Create SSH Key

# Default (ED25519 recommended)
ssh-keygen -t ed25519 -C "[email protected]"

# RSA with 4096 bits
ssh-keygen -t rsa -b 4096 -C "[email protected]"

# Specify output file
ssh-keygen -t ed25519 -f ~/.ssh/my_key -C "[email protected]"

View Fingerprint

ssh-keygen -lf ~/.ssh/id_rsa.pub

# As MD5
ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub

View Public Key

cat ~/.ssh/id_rsa.pub

# Copy to clipboard (Linux)
cat ~/.ssh/id_rsa.pub | xclip -selection clipboard

# Copy to clipboard (macOS)
cat ~/.ssh/id_rsa.pub | pbcopy

Change Passphrase

ssh-keygen -p -f ~/.ssh/id_rsa

Copy Key to Server

ssh-copy-id -i ~/.ssh/id_rsa.pub user@host

Key Types Overview

TypeFlagRecommended
ED25519-t ed25519✅ Yes
RSA-t rsa -b 4096⚠️ Legacy
ECDSA-t ecdsa⚠️ Limited
DSA-t dsa❌ Deprecated
💡Tip

ED25519 is the recommended key type as it provides strong security with shorter key lengths compared to RSA.

📝Note

Your public key (*.pub) can be shared freely, while your private key should never be shared with anyone.