2

I have run into an issue with WordPress and ssh. Essentially,I am trying to enable auto updating with Wordpress over SFTP. I have followed the directions on This thead on DigitalOcean.com up I have a user called wpftp.

SSHd into the server as a sudoer, I then login to the server as that user using login wpftp and entered the password. I then ran ssh-keygen -t rsa -b 4096 and exit.

Back as the sudo user, I ran chown -R wpftp:www-data .ssh/ than chmod 0640 .ssh/* than chmod 0700 .ssh

ls -lah gives me the following for .ssh folder

drwx------ 2 wpftp www-data 4.0K Jan 14 09:00 .ssh

looks good so far …

cd .ssh/
cp id_rsa.pub authorized_keys
chown wpftp:www-data *

gives me the following

-rw-r----- 1 wpftp www-data  747 Jan 14 09:04 authorized_keys
-rw-r----- 1 wpftp www-data 3.2K Jan 14 09:00 id_rsa
-rw-r----- 1 wpftp www-data  747 Jan 14 09:00 id_rsa.pub

Added from="127.0.0.1" to the authorized_keys at beginning

Popped the following into wp-config.php

define('FTP_PUBKEY','/home/wpftp/.ssh/id_rsa.pub');
define('FTP_PRIKEY','/home/wpftp/.ssh/id_rsa');
define('FTP_USER','wpftp');
define('FTP_PASS','');
define('FTP_HOST','127.0.0.1:22');

I also had an alternate config that I tried, also did not work

define('FS_METHOD', 'ssh2');
define('FTP_BASE', '/usr/share/nginx/wordpress');
define('FTP_CONTENT_DIR', '/usr/share/nginx/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/usr/share/nginx/wordpress/wp-content/plugins/');
define('FTP_PUBKEY', '/home/wpftp/.ssh/id_rsa.pub');
define('FTP_PRIKEY', '/home/wpftp/.ssh/id_rsa');
define('FTP_USER', 'wpftp');
define('FTP_PASS', '');
define('FTP_HOST', '127.0.0.1:22');
define('FTP_SSL', true);

I am getting the following error on the wordpress admin panel:

Public and Private keys incorrect for wpftp

I look at /var/log/auth.log and it says

Jan 14 09:09:17 localhost sshd[18313]: Received disconnect from 127.0.0.1: 11: PECL/ssh2 (http://pecl.php.net/packages/ssh2) [preauth]
Jan 14 09:09:20 localhost sshd[18315]: Received disconnect from 127.0.0.1: 11: PECL/ssh2 (http://pecl.php.net/packages/ssh2) [preauth]
Jan 14 09:09:48 localhost sshd[18318]: Received disconnect from 127.0.0.1: 11: PECL/ssh2 (http://pecl.php.net/packages/ssh2) [preauth]

I then went through the common issues on the article mentioned above

1 . Improper permissions on the public key, private key, and the directories that contain them.

/home/wpftp/.ssh/# ls -lah | grep .ssh
drwx------ 2 wpftp www-data 4.0K Jan 14 09:04 .ssh

/home/wpftp/.ssh/# cd .ssh
/home/wpftp/.ssh/# ls -lah
-rw-r----- 1 wpftp www-data  764 Jan 14 09:06 authorized_keys
-rw-r----- 1 wpftp www-data 3.2K Jan 14 09:00 id_rsa
-rw-r----- 1 wpftp www-data  747 Jan 14 09:00 id_rsa.pub

I also checked the nginx user

# ps aux | grep nginx
root     nginx: master process /usr/sbin/nginx
www-data  nginx: worker process
www-data nginx: worker process

#ps aux | grep php
root     18274  0.0  0.1 253360  5476 ?        Ss   09:07   0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)      
www-data php-fpm: pool www                                         
www-data php-fpm: pool www                                         
www-data php-fpm: pool www  
(several more pools follow)

I also checked the php5-fpm and nginx error logs, nothing pops up there

Improper file formatting. If your public or private key has formatting issues, WordPress will reject the key and refuse to use it. The same goes for the ~/.ssh/authorized_keys file. I Checked the id_dsa.pub and it was fine, I am able to ssh wpftp@localhost and get in no problem …

This problem has been quite frustrating as the errors are non-descriptive. I've checked several threads and tried applying the fixes but to no avail. I have installed the ssh2 library with apt-get install … Any thoughts?

Other References I checked:

Wordpress SSH Upgrade Problem

http://wordpress.org/support/topic/private-key-incorrect-for-user-error

http://wordpress.org/support/topic/private-key-incorrect-for-wordpress

http://chocotech.blogspot.com/2013/02/update-wordpress-by-using-ssh2-sftp.html

3
  • 1
    You'd probably have more success with wordpress.org/plugins/ssh-sftp-updater-support . Unlike the built-in SFTP update method this one doesn't require the key live on the file system and all the problems that come with that.
    – neubert
    Jan 15, 2014 at 19:04
  • Thinking you're probably right, will have to re-enable password authentication to get this up and running, thanks
    – Drazion
    Jan 16, 2014 at 14:39
  • Running into the exact same issue. Removing from="127.0.0.1" from the authorized keys resolves it, however clearly would like that left in since it will increase security. Will let you know if I discover more. Mar 22, 2015 at 14:44

1 Answer 1

-2

Why use SFTP?

Give WordPress to write permission then it will be solved.

u said you're using Nginx then set

chown -r nginx:nginx /var/www/html

replace /var/www/html with your site dir path so WordPress will able to update automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .