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 The_Idiot

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.

25 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.

    • TheIdiotWhisperer

      When you open the console (if on an Ubuntu server) start by typing the word “root” and hit enter. It will ask you for the root password. If you do not know your root password you can change the root password via the DO dashboard. Under your droplet click on “Access” and there you will see an option to email you your root password. When you enter this new password you will be required to change it immediately via the console though (for security purposes)

  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!!!

    • TheIdiotWhisperer

      NOT A DUDE!

      • Kapil

        Ok, Sorry Madam!

  12. Ismar

    did not work for me

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

    • TheIdiotWhisperer

      Uh… I am not a man. Please dont call me “sir”

  14. john

    Is there a way to block other users with root credentials from using ssh and ftp?
    Is there a way to access server without adding ssh in your droplet?

  15. Viktor

    You are the best girl in the world!

  16. Thomas

    Thanks so much!

  17. What we arrogate here is , a intermittentlydole
    Dependable click on the jam distress of the day-star to organize

  18. Thx for the tip and LOL @ the dudes calling you a dude/sir. Your responses were great. 😀

  19. StephaLog

    Hi guys! I want to try anal for a long time. But I’m afraid. If you are ready to help me, come in

    It’s me:


  20. Nobody Special

    Omg it worked thank you. I was trying for a month to fix this.

  21. Thank You!

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="">