Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1822
  • Last Modified:

Public and Private keys incorrect for user

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
Ashraf Hassanein
Asked:
Ashraf Hassanein
  • 5
  • 5
1 Solution
 
MazdajaiCommented:
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
 
Ashraf HassaneinAuthor Commented:
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
 
MazdajaiCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Ashraf HassaneinAuthor Commented:
Yes the same error!
0
 
MazdajaiCommented:
Can you post the commands you trying to run and the exact error?
0
 
Ashraf HassaneinAuthor Commented:
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
 
MazdajaiCommented:
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
 
Ashraf HassaneinAuthor Commented:
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
 
Ashraf HassaneinAuthor Commented:
Great and helpful solution
0
 
MazdajaiCommented:
.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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now