How to Configure SSH Key Authentication on Linux
Password-based SSH login is vulnerable to brute-force attacks. SSH key authentication is faster and significantly more secure.
Generate a Key Pair
ssh-keygen -t ed25519 -C "[email protected]"
Copy the Public Key to the Server
ssh-copy-id user@server-ip
Disable Password Login
Edit /etc/ssh/sshd_config and set:
PasswordAuthentication no PubkeyAuthentication yes
Then restart SSH: sudo systemctl restart sshd