Digital Ocean Public Key Access Denied on existing droplet

For those who are trying to add a new key to an existing droplet – READ THIS!!!!

If you are getting the “Permission denied (publickey)” when trying to copy your public key to the server, you likely have password authentication disabled in your droplet.

How to fix this:
Log in to your DigitalOcean account and open the console for the drop you are trying to access. While inside the console do the following:

Scroll down to the very bottom and look for the following directives:

If UsePAM is set to ‘yes’ and PasswordAuthentication is set to ‘no’ change those to the opposite. It should read the following:

Then press

, type

(colon), and type

and hit

This will quit vim editor.

Now type

Now go back to your terminal or putty and pick up at the step where it has you copying your local rsa public key to the server. You should now be presented with a request for a password instead of public key denied. Type in your droplet password and hit enter. You should know be inside your server.

Now you can change those settings back from Putty or Terminal by typing the following:

Change the directives back to what they were and press esc, type : (colon), and type wq and hit enter



Now you can quit the session by typing

and try to login with just ssh by typing


Now you should be able to access your server via SSH with your newly created SSH key!

This was a PITA to figure out, but that is what got it all done for me.


About Lindsay

Self made millionaire.. Oops I mean web developer.. who started out learning how to build websites with tables and dreamweaver, I now almost entirely focus on CMS-based development, usually WordPress. I love coding and designing and regularly switch between my left and right brains.

14 thoughts on “Digital Ocean Public Key Access Denied on existing droplet

  1. Matt Webb

    You just totally saved my hide with this one.  I was totally convinced I was going to have to do a new droplet and start over again. Thank you so very much.

  2. Katia

    You just save my day! Thank you!!!

  3. Miguel

    I tried access trough DigitalOcean account (droplet console), but i need login and i don’t know it.

  4. Eddie

    You have added years to my life!  THANK YOU!

  5. David

    If you’re using Ubunti, instead of “reload ssh” use:

    sudo service ssh stop


    sudo service ssh start

  6. Mau

    This is awesome fix. Thanks a lot, this was driving me nuts.

  7. Hi, Thanks for sharing the information. These tips are really helpful to us. Reading this article gave me many things to think about. You have some quality information here that any reader would enjoy. I share many of your views in this article.

    For more details please :-

  8. Gjoni

    I LOVE you!!!

  9. Raleigh Habersberger

    Thanks, that worked.

  10. Sila

    Thank you!!!!!


  11. Kapil

    Awesome dude!!!

  12. Ismar

    did not work for me

  13. It’s easier than Forex. It’s not sheer luck, though! $ 151 430 Paid to our traders yesterday. $ 152 735 Paid to our traders yesterday. Register now and get 10.000 virtual FUNDS in case of right forecast! This is FREE! далее тут

  14. <b>YOU SIR, ARE TRULY A WIZARD! Thank you so much!</b>

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">