I had my Ubuntu 15.10 system working just fine, and Wordpress updates happened over ssh. But when I upgraded Ubuntu to 16.04, the switch to php7.0 broke Wordpress updates. At first it was prompting for FTP login credentials until I installed php-ssh2 (which cautions that it's based on a git snapshot). Now when I try to upgrade a plugin, it says

An error occurred while updating WP to Twitter: Unable to locate WordPress Content directory (wp-content).

And in /var/log/apache2/error.log:

[Sun Jun 12 11:01:10.969931 2016] [:error] [pid 5545] [client] PHP Warning:  file_put_contents(): Unable to open ssh2.sftp://Resource id #81/.maintenance on remote host in /home/blog/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on line 252, referer: http://xxxx.com/wp-admin/update-core.php?action=do-plugin-upgrade
[Sun Jun 12 11:01:10.970772 2016] [:error] [pid 5545] [client] PHP Warning:  file_put_contents(ssh2.sftp://Resource id #81/.maintenance): failed to open stream: operation failed in /home/blog/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on line 252, referer: http://xxxx.com/wp-admin/update-core.php?action=do-plugin-upgrade

Am I missing a package, or a configuration item, or what?

4 Answers 4


I had the same problem. This seems to be a bug in php-ssh2 (from the Ubuntu repo).

After removing php-ssh2, and installing a newer version with pecl (pecl install ssh2-1.0), the problem was solved.

I submitted a bug report: https://bugs.launchpad.net/ubuntu/+source/php-ssh2/+bug/1617294

  • 1
    Well, that was easy. I didn't know about pecl. Aug 27, 2016 at 17:27
  • @Rick After burning half a Saturday trying to figure this out, your solution solved it in under 5 minutes. Thanks for sharing this! Sep 8, 2016 at 9:16
  • 1
    Alternative to pecl: you can also choose to use the package from Yakkety. For me it didn't give compatibility issues. Dec 18, 2016 at 15:42
  • Using pecl somehow did not work out for me even after installing php7.0-dev (the pecl command ended with a Segmentation Fault!). Hugos solution with getting php-ssh2 from Yakkety is much easier!
    – falstaff
    Jan 18, 2017 at 6:08
  • And all of a sudden the problem is back! [Fri Jan 27 09:00:45.336663 2017] [:error] [pid 17823] [client] PHP Warning: file_put_contents(ssh2.sftp://Resource id #85/.maintenance): failed to open stream: operation failed in /home/blog/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php on line 253, referer: blog.xcski.com/wp-admin/… Jan 27, 2017 at 14:05

Installing the pecl extension didn't worked for me (Who knows why) but I found an alternative:

I just uploaded this Plugin via scp to my VPS and it solved the problem: https://wordpress.org/plugins/ssh-sftp-updater-support/


In my case none of the above worked, however, a patch by ralphm in the PHP code fixed the update-via-ssh2-problem for WordPress on both Ubuntu 14.04 and Ubuntu 16.04 for me:

--- a/wp-admin/includes/class-wp-filesystem-ssh2.php
+++ b/wp-admin/includes/class-wp-filesystem-ssh2.php
@@ -185,7 +185,7 @@
        if ( '/' === $path ) {
            $path = '/./';
-       return 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim( $path, '/' );
+       return 'ssh2.sftp://' . intval($this->sftp_link) . '/' . ltrim( $path, '/' );


Do not forget to reapply this patch after updating until a final fix makes it to the WordPress release.

  • Thanks for this! Worked for me without having to mess with pecl Nov 29, 2017 at 13:33

In my case only Installing version of 1.1.2 lib helped...
pecl install ssh2-1.1.2

  • PHP 7.0.22-0ubuntu0.16.04.1
  • Apache/2.4.18

You must log in to answer this question.

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