How do you set up SSH key authentication?

Answer

SSH key authentication uses asymmetric cryptography to authenticate without passwords. Steps: (1) Generate a key pair on the client: ssh-keygen -t ed25519 -C "your_email" (or RSA: -t rsa -b 4096). This creates ~/.ssh/id_ed25519 (private) and ~/.ssh/id_ed25519.pub (public). (2) Copy the public key to the server: ssh-copy-id user@server (or manually append to ~/.ssh/authorized_keys on the server). (3) Ensure server permissions: ~/.ssh must be 700, authorized_keys must be 600. (4) Optionally disable password auth in /etc/ssh/sshd_config: set PasswordAuthentication no. Use ssh-agent and ssh-add to avoid entering the passphrase repeatedly.