WordPress, ssh2, libssh and pecl – securely updating your WordPress plugins

I don’t want to run FTP on my webserver, sorry. WordPress can be convinced to update itself using SSH, but pecl install ssh2 is needed for it to work.

If you don’t want to fuss with pecl, there’s a plugin which can setup updates via ssh, but it involves configuration for each site in a multisite setup, and was more hassle than I wanted in my life. So it’s back to pecl, but I ran into an issue with precious little on the googles to help with this.

So, here’s the solution which worked for me…

apt-get install php-pear php5-dev
mkdir libssh2install
cd libssh2install
wget http://www.libssh2.org/download/libssh2-1.4.3.tar.gz
tar -zxvf libssh2-1.4.3.tar.gz
cd libssh2-1.4.3/
./configure
make
make install
pecl install "channel://pecl.php.net/ssh2-0.11.3"

Gave me a very welcome Build process completed successfully

Installing '/usr/lib/php5/20121212/ssh2.so'
install ok: channel://pecl.php.net/ssh2-0.11.3
configuration option "php_ini" is not set to php.ini location
You should add "extension=ssh2.so" to php.ini

Looks like it worked!

Now we need to edit the active php configuration for your install, I did this:

sudo echo /etc/php5/cli/conf.d/20-ssh2.ini > extension=ssh2.so
service apache2 restart

I got some of this information from this post by Henning Glatter-Götz, and he’s got the rest of the steps needed in WordPress are laid out  well.

So, here’s the hard parts of getting WordPress updating via ssh. Hope this helps you!