Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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 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

Added from="" to the authorized_keys at beginning

Popped the following into wp-config.php


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/');
define('FTP_PRIKEY', '/home/wpftp/.ssh/id_rsa');
define('FTP_USER', 'wpftp');
define('FTP_PASS', '');
define('FTP_HOST', '');
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 11: PECL/ssh2 ( [preauth]
Jan 14 09:09:20 localhost sshd[18315]: Received disconnect from 11: PECL/ssh2 ( [preauth]
Jan 14 09:09:48 localhost sshd[18318]: Received disconnect from 11: PECL/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

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 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

share|improve this question
You'd probably have more success with . 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 '14 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 '14 at 14:39
Running into the exact same issue. Removing from="" 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. – cchiera Mar 22 '15 at 14:44

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.