Backing up your SSH keys
Backup
# 1. Identify your key files (common names: id_ed25519, id_rsa)ls -la ~/.ssh
# 2. Check the public-key fingerprint so you can verify the backup laterssh-keygen -lf ~/.ssh/id_ed25519.pub
# 3. Create an encrypted backup archive containing only this key pairtar -C "$HOME" -czf - .ssh/id_ed25519 .ssh/id_ed25519.pub \ | gpg --symmetric --cipher-algo AES256 --output "$HOME/id_ed25519-backup.tgz.gpg"
# 4. Restrict access to the resulting backup filechmod 600 "$HOME/id_ed25519-backup.tgz.gpg"Restore
gpg --decrypt "$HOME/id_ed25519-backup.tgz.gpg" \ | tar -xzf - -C "$HOME"
chmod 700 ~/.sshchmod 600 ~/.ssh/id_ed25519chmod 644 ~/.ssh/id_ed25519.pub
# Confirm the restored public key has the expected fingerprintssh-keygen -lf ~/.ssh/id_ed25519.pub