# Generate a key pair (Ed25519 recommended)ssh-keygen-ted25519-C"john@example.com"ssh-keygen-ted25519-C"work key"-f~/.ssh/id_work
# Generate a key pair (RSA fallback for legacy systems)ssh-keygen-trsa-b4096-C"john@example.com"# Recover public key from private keyssh-keygen-f~/.ssh/id_ed25519-y>~/.ssh/id_ed25519.pub
# Show fingerprint of a keyssh-keygen-lf~/.ssh/id_ed25519.pub
ssh-keygen-lf~/.ssh/id_ed25519.pub-Emd5# MD5 format (for older systems)# Copy public key to remote hostssh-copy-iduser@host
ssh-copy-id-i~/.ssh/id_work.pubuser@host
# Jump through a bastion (one-liner)ssh-Jbastion.example.comuser@10.0.0.5
# Local port forward — access remote service locally# http://localhost:8080 → remote:80ssh-L8080:localhost:80user@host
# Access a host behind a bastionssh-L5432:db.internal:5432user@bastion
# Remote port forward — expose local port on remotessh-R9090:localhost:3000user@host
# Dynamic SOCKS proxyssh-D1080user@host
# then: curl --socks5 localhost:1080 http://example.com# Keep tunnels alive in backgroundssh-fNL8080:localhost:80user@host
# -f: background -N: no command -L: local forward
# Start agenteval"$(ssh-agent-s)"# Add a key (prompted for passphrase once)ssh-add~/.ssh/id_ed25519
ssh-add~/.ssh/id_work
# Add with TTL (forget after 8 hours)ssh-add-t8h~/.ssh/id_ed25519
# List loaded keysssh-add-l
# Remove all keysssh-add-D