SSH keys are safer and more convenient than passwords when used correctly.
Create a key pair
ssh-keygen -t ed25519 -C "your-email@example.nz"
Copy the key to your server
ssh-copy-id root@YOUR_SERVER_IP
Good practice
- Use a passphrase on your private key.
- Never share your private key.
- Remove keys that are no longer used.
- Keep a recovery method available before disabling password login.