Skip to content
VdsRent
Beginner5 min read

Set up SSH keys and disable password logins

The single highest-value change you can make to a new server.

Last updated 1 August 2026

Generate a key

bash
ssh-keygen -t ed25519 -C "you@example.com"

Accept the default location and set a passphrase. The passphrase protects the key on your own machine; it is never sent anywhere.

Copy it to the server

bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@203.0.113.24

Turn off password authentication

Keep your current session open

Open a second terminal and confirm the key works before you change the configuration. If the change is wrong, the open session is how you undo it.
bash
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl reload sshd

Was this page useful?

Feedback about article ssh-keys
Set up SSH keys and disable password logins — Guide — VdsRent