Solved

Public and Private keys incorrect for user

Posted on 2014-01-30
10
1,676 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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
 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate PDF's using TCPDF - Initial Set Up 9 33
Put POST values into cookies. 14 34
Add social media icons to blog post 4 20
Find RGB colors from a screen. 2 19
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
Fine Tune your automatic Updates for Ubuntu / Debian
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

726 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