Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Public and Private keys incorrect for user

Posted on 2014-01-30
10
1,652 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to dynamically set the form action using jQuery.

828 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