How to set up SSH key authentication
Updated 7/20/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 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 7/20/2026SecurityHow to scan your server for malware with ClamAV
Install ClamAV, an open-source antivirus, and periodically scan your server for infected files.
Updated 7/20/2026SecurityHow to add security headers to your website
A few HTTP headers protect your visitors from common attacks like clickjacking and content injection.
Updated 7/20/2026