Question

Cannot ssh into my droplet with or with out password / with or without ssh pairs

Posted December 17, 2020 272 views
DigitalOceanUbuntu 20.04

I am revisiting my application on digitalocean but my keys were on a hard drive that just died. I tried using putty to initiate ssh and it asked me for my username, which I did not know so I went about changing the password inside digital ocean.
I was able to access the terminal inside digital ocean but it would not let me modify any files. I suppose I need to change permissions but since I lost root access, I am at a loss as to what to do.
Every time I try to enter either via git bash or putty, I get an error. In gitbash, Permission denied (publicKey). In Putty, Server refused your key. I followed about 11 tutorials and no luck. I have the private key stored in my .ssh folder as private.ppk as well as my public key.
I copied the single line code into the interface provided by digitalocean and gave it a unique name. In putty, I pointed to the private key.
If anyone can help me with this I would greatly apprecate it. Thank you in advance.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi @kukulcanwar,

The eaisiest thing to do is, enter your DigitalOcean Droplet Console and from there add your new SSH KEY to the

~/.ssh/authorized_keys

file, OR enable PasswordAuthentication from the sshd_config file located in

/etc/ssh/sshd_config

Once you edit the file don’t forger to restart your sshd service

service sshd restart

Regards,
KFSys

  • Thank you for your reply @KFSys
    When you say /authorized_keys, are you saying for example: ~/.ssh/my-public-key.pub??? Thank you

    • Hi @kukulcanwar,

      You need to add your .pub key to your server’s authorized_keys.

      Basically, you can take ~/.ssh/my-public-key.pub from your laptop and put it inside ~/.ssh/authorized_keys on your droplet.

  • Another question… Using the console, I get nowhere. The console just doesn’t want to load no matter what browser I am using. I have used firefox, edge and chrome(chrome being the worst in this case). So my question is, what are the alternatives in this case.

    • Hi @kukulcanwar,

      Can you try using an incognito browser to see if it would work properly?

      Most probably you’ve blocked the popup console or something similar, please give incognito browser a try.

Hello, @kukulcanwar

You can enable PasswordAuthentication for your Droplet by modifying your /etc/ssh/sshd_config file. Once set to Yes restart the SSH service and connect via an SSH client for a more stable connection. You can then modify your ~/.ssh/authorized_keys file to add the appropriate public key.

This change can be made from the DigitalOcean’s console. If you’re having issues to access the console you can than reach to our amazing support team that can help you further with this.

To enable the PasswordAuthentication follow these steps:

  1. Login to the console on DigitalOcean website.
  2. Type sudo nano /etc/ssh/sshd_config
  3. Change PasswordAuthentication from “no” to “yes” and save the file
  4. Open a terminal on your computer and type ssh username@[hostname or IP address] or if on a Windows box use PuTTY for password login making sure authentication parameters aren’t pointing to a private key
  5. Login with password
  6. Type sudo nano ~/.ssh/authorized_keys
  7. Paste public key text here and save the file
  8. Type sudo nano /etc/ssh/sshd_config
  9. Change PasswordAuthentication from “yes” to “no” and save the file
  10. Log out and attempt to log back in (if using PuTTY make sure you set up auth parameters to point to your private key)

Hope that this helps!
Regards,
Alex