Linux: Installing SSH2 for PHP5

      1 Comment on Linux: Installing SSH2 for PHP5

Note: This method has been deprecated with the release of WordPress 3 – in Ubuntu/Debian, you now only need to run the following as root:

And you’re done!

I just installed WordPress 2.7 today. Boy, is it exciting! The entire interface is different, and things can be accomplished much more quickly.

One of the neat features is the ability to add and remove plugins from the web interface. Unfortunately, WordPress only works with FTP and FTPS (FTP over SSL) by default. I don’t have an FTP server installed on my Linode, so I decided to see if I could use SSH instead.

Turns out it’s possible, but it sure was a beast to get up and running. I’ll go through what I did, in case anyone else had as much trouble with this as I did.

First off, you need to install PEAR. This is a nifty little utility that can automatically compile PHP extensions.

Keep in mind that I’m working in Ubuntu 8.04.1 here, and my Linode installation is very stripped down.

First, you need to install the command-line interface for PHP, which allows you to run PHP scripts from a terminal.

Seeing as my installation of Ubuntu is devoid of pretty much any extras, I needed to install wget too.

Once that’s done, we can install PEAR.

Once the PEAR installation script is running, you need to configure the locations of each of the components. I chose to stick everything in /pear, but you may want to put it somewhere else. I’d recommend keeping option 3 to my setting, though.

Now that PEAR is installed, we can get into installing OpenSSL and the necessary packages to make it work with PHP.

With our libraries and packages installed, we can compile our ssh2 extension for PHP.

Finally, we need to add the extension to php.ini.

Find the section titled “Extensions” and add this line:

And restart Apache:

In your WordPress admin interface, you should now see an “SSH” option when you go to add, remove, or update files on your server. WordPress provides text boxes to use your private and public SSH keys, but I found I only needed to use one of my user account’s credentials to authenticate to the server.

One thought on “Linux: Installing SSH2 for PHP5

  1. Steve

    I know this is a very old post but I’m still running 8.04 LTS and wanted to add SSH support for WordPress and your post gave the perfect solution, and the quickest too!



Leave a Reply

Your email address will not be published. Required fields are marked *