Solved

Public and Private keys incorrect for user

Posted on 2014-01-30
10
1,609 Views
Last Modified: 2014-02-02
I have wordpress 3.8 on centos 6.3 installed in
/home/wp

Open in new window


The directory is the home directory for wp-user
I have tried all the way to configure the wordpress ssh to install pliugins but I am always getting:
Public and Private keys incorrect for wp-user

The directory of wp-user is:
drwxr-xr-x   5 wp-user wp-user 4096 Jan 30 11:10 .
drwx------   2 wp-user wp-user 4096 Jan 30 11:10 .ssh
-rw-------   1 wp-user wp-user 4498 Jan 30 11:10 .viminfo
drwxr-xr-x   5 wp-user wp-user 4096 Jan 30 11:10 wordpress
-rw-------   1 wp-user wp-user  445 Jan 30 10:56 .bash_history
-rw-r-----   1 wp-user wp-user 1743 Jan 30 10:51 id_rsa
-rw-r-----   1 wp-user wp-user  400 Jan 30 10:51 id_rsa.pub
drwxr-xr-x   2 wp-user wp-user 4096 Jan 30 10:49 .vim
drwxr-xr-x. 10 root    root    4096 Jan 30 10:31 ..
-rw-r--r--   1 wp-user wp-user   18 Jul 18  2013 .bash_logout
-rw-r--r--   1 wp-user wp-user  176 Jul 18  2013 .bash_profile
-rw-r--r--   1 wp-user wp-user  124 Jul 18  2013 .bashrc

Open in new window


The permissions of the authorized_keys:
-rw-r--r-- 1 wp-user wp-user  400 Jan 30 11:10 authorized_keys

Open in new window


The contents of the authorized_keys:
from="127.0.0.1" ssh-rsa xxxxxxx == wp-user@mydomain.com

Open in new window


The contents of the id_rsa.pub
ssh-rsa xxxxxxx == wp-user@mydomain.com

Open in new window



Config in wp-config.php
efine( 'FTP_BASE', '/home/wp/wordpress/' );
define( 'FTP_CONTENT_DIR', '/home/wp/wordpress/wp-content/' );
define( 'FTP_PLUGIN_DIR ', '/home/wp/wordpress/wp-content/plugins/' );
define( 'FTP_PUBKEY', '/home/wp/id_rsa.pub' );
define( 'FTP_PRIKEY', '/home/wp/id_rsa' );
define( 'FTP_USER', 'wp-user' );
define( 'FTP_PASS', 'passphrase' );
define( 'FTP_HOST', '127.0.0.1:22' );

Open in new window


How can I solve this issue?
0
Comment
Question by:Ashraf Hassanein
  • 5
  • 5
10 Comments
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39822745
1 authorized_keys needs to be 600, try
chmod 600 authorized_keys

Open in new window

2. Use mds5sum to compare the authorized_keys and id_rsa.pub. If this is your only pub key on authorized_key they should match.

If it still fails post a verbose ssh session by invoking the -vvv flag

ssh -vvv host

Open in new window

0
 

Author Comment

by:Ashraf Hassanein
ID: 39822837
I have changed the permissions of the authorized_keys and check the mds5sum for both the authorized_keys and id_rsa.pub and they are indentical, when I did ssh -vvv host for the command line it worked perfectly I believe that there is something the WP config then.
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39823159
when I did ssh -vvv host for the command line it worked perfectly

Open in new window

If you can login passwordless then the keys are fine. Are you getting the same error or different error?
0
 

Author Comment

by:Ashraf Hassanein
ID: 39823298
Yes the same error!
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39824594
Can you post the commands you trying to run and the exact error?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:Ashraf Hassanein
ID: 39825365
From the linux level I do not have any error I can ssh to the local host with no password, but my problem is with the wordpress when it tries to use SSH it gives this only vague error:

 Public and Private keys incorrect for wp-user

Open in new window

0
 
LVL 21

Accepted Solution

by:
Mazdajai earned 500 total points
ID: 39825876
Try moving the keys into .ssh and make the private key to 600.

define( 'FTP_PUBKEY', '/home/wp/.ssh/id_rsa.pub' );
define( 'FTP_PRIKEY', '/home/wp/.ssh/id_rsa' );

Open in new window


If all fail generate a fresh pair of keys and copy to authorized_keys.
0
 

Author Comment

by:Ashraf Hassanein
ID: 39825949
Thank you so much for your help, this indeed help, also I have changed the permissions for the .ssh to:
chmod 755 .ssh

Open in new window

drwxr-xr-x   2 wp-user wp-user     4096 Feb  1 07:53 .ssh

Open in new window


And the Contents of .ssh to:
chmod 644 .ssh/id_rsa

Open in new window

-rw-r----- 1 wp-user wp-user  400 Feb  1 07:53 id_rsa.pub
-rw------- 1 wp-user wp-user  417 Jan 31 21:30 authorized_keys
-rw-r--r-- 1 wp-user wp-user  391 Jan 31 21:30 known_hosts
-rw-r--r-- 1 wp-user wp-user 1675 Jan 31 21:22 id_rsa

Open in new window


And surprisingly it is working thanks for your help.
However the ssh from the linux command line is not working but that not a problem or you think it is a security hole?
0
 

Author Closing Comment

by:Ashraf Hassanein
ID: 39827040
Great and helpful solution
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39827801
.ssh needs to be .700.  If you continue having an issue with ssh and keys, I would suggest opening a new thread.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now