What you can do is to access your droplet via the console from your DigitalOcean’s control panel and then make sure that your
ssh-key is added or you can enable the PasswordAuthentication and then access the droplet from your machine and then add your keys and tweak the configuration if needed.
If you access the droplet via the console you can check if your key is present in the
~/.ssh/authorized_keys file and if not you can add it and this should sort the connectivity issue for you. However if you’re finding difficulties to do so due to issues with the text editor or copying/pasting the key there is another way to achieve this.
You can tweak temporary tweak the ssh configuration and allow PasswordAuthentication in order to access your droplet from your PC. In order to do that you need to access the droplet from the console again.
Use vim or nano to edit the contents of
vi /etc/ssh/sshd_config or
Now go to the very bottom of the file (to the line with PasswordAuthentication) - Change the value next to
PasswordAuthentication from no to yes.
It should now look like this:
# Change to no to disable tunnelled clear text passwords
Save the file and then run the following command to reload the SSH config:
sudo service sshd reload
With this done, you can now set up your new SSH key for your LOCAL device.
To do this, you can run the following from your LOCAL device, not the server:
Alternatively, you can paste in the keys using SSH:
cat ~/.ssh/id_rsa.pub | ssh email@example.com "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
Note: You need to change username and droplet.ip with your actual username and Droplet’s IP address
Hope this helps!
Let me know how it goes.