If you want to use SSH2 with PHP (say you built a custom deployment system) you need the SSH2-extension for php. Here is how you get it to work using MAMP on OSX.

I recently wrote an article on how you get the autotools installed on osx. Do this first – you ned autoconf, automake and libtools.

Then installing the SSH2 extension is easy as pie:

  1. Install the autotools
  2. Install libssh (as root)
  3. build the ssh2-extension using pecl (you have to give pecl the absolute path, because ssh2 is still beta)

Here is how this looked like on my cli:

cd /usr/local/src
sudo bash
curl -OL http://www.libssh2.org/download/libssh2-1.4.3.tar.gz
tar xzf libssh2-1.4.3.tar.gz
cd libssh2-1.4.3
./configure --prefix=/usr/local/
make install
cd /Applications/MAMP/bin/php/php5.3.6/
./bin/pecl install channel://pecl.php.net/ssh2-0.12

Now the only thing remaining is enabling the module in your php.ini.