Wordpress SSH : Public and Private keys incorrect for wp-user

March 26, 2016 3.4k views
DigitalOcean WordPress Ubuntu

I followed the instructions for setting up SSH to the letter, even using the same username as wp-user.

When I try to install a plugin, it comes up with "Public and Private keys incorrect for wp-user"

I generated the key pair several times. Same problem!

When it didn't work after several regens, I decided to generate my own using puTTY and then uploaded it to the /home/wp-user directory as wp_rsa, wp_rsa.pub.

In the Wordpress Connection Information page, it shows the following:

Hostname
127.0.0.1:22

FTP/SSH Username
wp-user

FTP/SSH Password
..... (I did not give wp-user a password as instructed not to)

Authentication Keys

Public Key:
/home/wp-user/wp_rsa.pub

Private Key:
/home/wp-user/wp_rsa

Connection Type
SSH2

==================

I've been at this from morning to now evening. Frustrating.

Anyone have any idea why this isn't working? TIA.

3 comments
  • Still have this problem. Cannot install plugins or themes as SSH2 does not work.
    "Public and Private keys incorrect for wp-user"

    Anyone have any ideas?

  • SOLVED!!!

    I'm posting this here so that if someone else has this frustrating problem this might solve it.

    Here is what I found:

    Try to give www-data permission in wordpress directory:

    cd /yourwordpress_dir/
    sudo chown -R www-data:www-data *

    In my case, I had to cd /var/www/html and then sudo chown -R www-data:www-data *

    :-)

  • @rick741284 I believe you're referring to this tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-secure-updates-and-installations-in-wordpress-on-ubuntu

    The whole idea is to prevent the server process (www-data) from having ownership to your WordPress install. Hence, the need to create a separate user for WordPress (ie wp-user) and assign ownership of your install to that user. Changing ownership of your WordPress install back to www-data (instead of wp-user) defeats that purpose.

    You actually do not need to go through the whole wp-user ssh trouble if you want www-data to own your WordPress install.

    I'm not sure why your process did not work, and I've not tested the tutorial myself. But maybe you should go over the process again and pay close attention to the permission bits.

    Happy surfing :-)

    by Justin Ellingwood
    WordPress is the most popular content management system (CMS) on the web currently. While WordPress can be a great way to manage you content, there are some very insecure configurations that are given throughout the internet. This article will cover how to set up secure updates and installations using SSH keys instead of FTP, which is an inherently insecure protocol.
3 Answers

This question was answered by @rick741284:

SOLVED!!!

I'm posting this here so that if someone else has this frustrating problem this might solve it.

Here is what I found:

Try to give www-data permission in wordpress directory:

cd /yourwordpress_dir/
sudo chown -R www-data:www-data *

In my case, I had to cd /var/www/html and then sudo chown -R www-data:www-data *

:-)

View the original comment

Thank you for this - it also solved my problem :)

Thank you a lot @rick741284! You solved my problem! :D

Have another answer? Share your knowledge.