Log in to DigitalOcean via ssh with password

How to add ssh public key to authorized_keys on DigitalOcean Droplet

First thing you probably tried was pasting the public key to authorized_keys via console tool offered by DigitalOcean. Sounds easy and obvious but DigitalOcean’s console changes some characters during the pasting, so your key will be in total mess. Writing it character by character also doesn’t sound like a fun.
You need to get access to your droplet from your favourite terminal of choice.

To do it we have to use DigitalOcean’s console only to make a small change in /etc/ssh/sshd_config file.Change PasswordAuthentication to yes and restart the service

 systemctl restart sshd

Now try to log in to your droplet from your terminal

ssh root@<ip-address>

You will be asked for your Droplet’s password. Enter it and you are in. If you forgot your password you can change it from DigitalOcean’s Droplet settings. “Reset root password” can be found in “Access” panel.

Now you can paste your public key to authorized_keys.
Don’t forget to set PasswordAuthentication back to no in /etc/ssh/sshd_config file