This guide shows how to add an SSH key to your Debian/Ubuntu VPS.
Make sure to have your public key ready. On Windows, you can use eg. Puttygen to generate one https://www.puttygen.com/.
Login to your VPS using your username and password and change to the root user using "su -".
Create a .ssh directory:
Create an ssh public key file:
Paste your PUBLIC! key in here. Do not paste your private key on the server.
Open the SSH config file:
Disable password authentication by adding this line:
In the sshd_config you can also change the SSH port, which we recommend.
To apply the changes make sure to reload the SSH Service with:
systemctl restart sshd.service
Before you close the active ssh connection make sure to open a new one and check if you can login!