How to set up SSH key authentication
Updated 10/16/2026
SSH keys are a pair of files: one public (on the server) and one private (with you). They are far more secure than passwords and eliminate the risk of brute-force attacks.
1. Generate a key pair (on your computer)
ssh-keygen -t ed25519 -C "[email protected]"
Press Enter for the default location and, optionally, set a passphrase for the key.
2. Copy the public key to the server
ssh-copy-id root@SERVER_IP
Or manually, add it to ~/.ssh/authorized_keys on the server.
3. Test the connection
ssh root@SERVER_IP
You should log in without a password.
4. Disable passwords (once the key works)
In /etc/ssh/sshd_config:
PasswordAuthentication no
systemctl restart ssh
Important
Keep the private key safe and never share it. Continue with disabling root login for extra security.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to scan your server for malware with ClamAV
Install ClamAV, an open-source antivirus, and periodically scan your server for infected files.
Updated 10/16/2026SecurityHow to check which ports are open on your server
Find out which services are listening for connections on your server and close what you do not need, for less exposure.
Updated 10/16/2026SecurityHow to set up your own VPN with WireGuard
Run your own private, fast and secure VPN with WireGuard on a VPS, for private browsing and secure access.
Updated 10/16/2026