If you have set up your Linux server so that authentication takes place via an SSH key, it is recommended that you disable password authentication altogether. This way you minimize the attack surface for your server immensely.
Disabling password authentication is actually quite simple. Open the configuration file /etc/ssh/sshd_config with a text editor (e.g. nano).
Find the line
#PasswordAuthentication yes
Remove the „#“ in this line. Replace the „yes“ – „no“ should be there at the end.
PasswordAuthentication no
Save the file and restart the SSH server. This can be done with the command:
service ssh restart
Leave the current SSH session open and start a new session in the new window. Now try if you can log in with the SSH key. If not, you should turn on password authentication again and solve this problem.
If you are still locked out, you can always connect to your server with VNC. There you can also use the root password, because this is not an SSH connection, but a direct terminal connection.