Here is how to do it on linux:
https://linuxize.com/post/how-to-set-up-ssh-keys-on-debian-10/
If you want to use Windows:
1.) get
puttygen.exe
2.) use puttygen to create a 4096bit RSA private public key pair. If you want more security you can also add a optional passphrase so the key file is useless without that passphrase. By default the private key will be in ppk format that only works with putty. So you might want to export a OpenSSH2 readable private key too.
3.) Store your private keys at a secure place and make backups of it
4.)
download and install putty (MSI for installation or just the putty.exe if you don't want to install it)
5.) Use putty to connect to your server as your unprivileged user using password
6.) switch to root user:
sudo su -
7.) Create a file to store the public key for your root user:
mkdir /root/.ssh
nano /root/.ssh/authorized_keys
Paste the content of your private key here (right click to paste). Make sure its all in one line. Save with CTRL+X.
chmod 0600 /root/.ssh/authorized_keys
8.) reboot server and try to login as root using putty. You will need to tell putty where your private key is stored (Connection -> SSH -> Auth -> Private keyfile for authentification).
9.) if that works you can disable SSH logins using passwords:
nano /etc/ssh/sshd_config
Change "#PasswordAuthentication yes" to "PasswordAuthentication no", save and reboot