Passwords get guessed; keys don't. Ten minutes to set up, and the bots lose interest.
Steps
This is for Linux. Keep your current SSH session open until the last step, so a typo can't lock you out. You'll need your Main IP.
- On your own computer, create a key:
ssh-keygen -t ed25519. Set a passphrase when asked. - Copy the public key to the server:
ssh-copy-id -o User=USERNAME YOUR.MAIN.IP(replaceUSERNAMEwith your login). - Open a second terminal and confirm the key works:
ssh -l USERNAME YOUR.MAIN.IP. It should ask for your key passphrase, not the account password. - On the server, open
/etc/ssh/sshd_configin an editor such assudo nano /etc/ssh/sshd_config. - Set
PasswordAuthentication no. - Set
PermitRootLogin prohibit-password, ornoif you log in as a normal user and usesudo. - Test the configuration:
sudo sshd -t. No output means no errors. - Reload SSH:
sudo systemctl reload sshd(on Debian or Ubuntu the service may be namedssh). - From a third terminal, confirm you can still log in with your key. Only then close your original session.
If it didn't work
- Locked out? Use the IPMI console (see our article on reaching IPMI) to log in locally, fix
/etc/ssh/sshd_config, and reload. - "Permission denied (publickey)": check that
~/.sshis mode700and~/.ssh/authorized_keysis mode600on the server. - Some Ubuntu releases don't allow direct root login by default; log in as the normal user and use
suorsudo. - Still stuck? Open a ticket in the portal, set Department to Technical Support, and include your Main IP and the exact error. Unmanaged servers get guidance only; hands-on work follows the unmanaged support terms.