An SSH key is a pair of files: a private key that stays on your computer and a public key you put on the server. It is far harder to break than any password.
1. Create a key
On Windows (PowerShell), macOS or Linux (Terminal):
ssh-keygen -t ed25519 -C "my-laptop"
Press Enter to accept the default location, and choose a passphrase for extra safety. This creates:
id_ed25519: your private key. Never share it.id_ed25519.pub: your public key. This one goes on the server.
2. Copy the public key to your VPS
On macOS or Linux:
ssh-copy-id root@YOUR_SERVER_IP
On Windows (PowerShell):
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh root@YOUR_SERVER_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Enter your password one last time.
3. Test it
ssh root@YOUR_SERVER_IP
You should get in without the server asking for a password (only your key passphrase, if you set one).
4. Turn off password logins
Only do this after step 3 works. Keep your current session open while you test, so you can fix mistakes.
Edit the SSH config:
nano /etc/ssh/sshd_config
Set:
PasswordAuthentication no
On newer Ubuntu versions also check the files in /etc/ssh/sshd_config.d/ for another PasswordAuthentication yes line and change it too. Then restart SSH:
systemctl restart ssh
Open a new terminal and log in again to confirm everything works before closing the old one.
Lost your key and locked out? Contact Slime Host support and we will help you get back in.