Question

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

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.

Subscribe
Share

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 :-)

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?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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

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

As mentioned, setting the entire wordpress path to www-data:www-data is insecure. At the minimum, you can get this to work by just setting wp-admin/includes/file.php permissions to www-data:www-data

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