SSH keys are more secure than passwords and prevent brute-force attacks.
Generate a Key Pair (on your local machine)
ssh-keygen -t ed25519 -C "your-email@example.com"Copy the Public Key to Your Server
ssh-copy-id user@YOUR_IP_ADDRESSOr manually:
cat ~/.ssh/id_ed25519.pub | ssh user@YOUR_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"Disable Password Authentication
Edit /etc/ssh/sshd_config:
PasswordAuthentication no
PubkeyAuthentication yessystemctl restart sshdKey Types
- Ed25519 — recommended, fast, secure
- RSA 4096 — widely compatible
- ECDSA — good alternative