Ssh2

About SSH2
This page shall be dedicated to compiling the SSH2 extension for php. Once installed, you'll be able to use these functions.

Additional Resources

 * PECL SSH2
 * Installing “Secure Shell2 (SSH2)” PHP Extension

Installing SSH2
Please Note: The installation of SSH2 requires Installing_PHP5 or Installing_PHP4.

If you are unable to do so, then you may not be able to use SSH2 on your DreamHost account.

Below is the install script for the SSH2 PHP module. I'm not a bourne/bash scripter so I am aware the code below is shit.

installssh2forphp.sh
set -e
 * 1) !/bin/sh

SRCDIR=${HOME}/src
 * 1) User Configuration Options
 * 2) Temporary src directory - WARNING: This will be wiped clean.

PHPDIR=${HOME}/php5
 * 1) Note: This *MUST* be set to your PHP5 installation directory!

PREFIXDIR=${HOME}/prefixdir

AUTOCONF="autoconf-2.61"
 * 1) Program Version Configuration

LIBSSH2="libssh2-1.1" LIBSSH2FEATURES="--prefix=${PREFIXDIR}"
 * 1) Don't touch unless you know what you're doing!

SSH2="ssh2-0.11.0" SSH2FEATURES="--prefix=${PREFIXDIR} --with-php-config=${PHPDIR}/bin/php-config --with-ssh2=${PREFIXDIR}"


 * 1) END User Configuration Options

sleep 1s
 * 1) DO NOT MODIFY BELOW ##########

export PATH=${PREFIXDIR}/bin:$PATH export PHP_PREFIX=${PHPDIR}/bin
 * 1) Push the install dir's bin directory into the path

if [ -d ${SRCDIR} ]; then echo "src directory already exists! Cleaning it..." rm -rf $SRCDIR/* else echo "Creating src directory..." mkdir -p ${SRCDIR} fi
 * 1) Clear and/or create the src directory.

cd ${SRCDIR}
 * 1) Check if packages already exist and get packages the ones that don't.

WGETOPT="-t1 -T10 -w5 -q -c"
 * 1) Wget options

if [ -a ${SRCDIR}/${LIBSSH2}.tar.gz ]; then echo "Skipping wget of ${LIBSSH2}.tar.gz" else wget $WGETOPT http://softlayer.dl.sourceforge.net/sourceforge/libssh2/${LIBSSH2}.tar.gz
 * 1) Do some of our own error checking here too.

if [ -a ${SRCDIR}/${LIBSSH2}.tar.gz ]; then echo "Got ${LIBSSH2}.tar.gz" else echo "Failed to get ${LIBSSH2}.tar.gz. Aborting install!" exit 0 fi fi

if [ -a ${SRCDIR}/${AUTOCONF}.tar.gz ]; then echo "Skipping wget of ${AUTOCONF}.tar.gz" else wget $WGETOPT ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/distfiles/${AUTOCONF}.tar.gz # If primary mirror fails, use the alternative mirror. if [ -a ${SRCDIR}/${AUTOCONF}.tar.gz ]; then echo "Got ${AUTOCONF}.tar.gz" else wget $WGETOPT ftp://ftp.gnu.org/gnu/autoconf/${AUTOCONF}.tar.gz # Check to make sure the alternative mirror worked. if [ -a ${SRCDIR}/${AUTOCONF}.tar.gz ]; then echo "Got ${AUTOCONF}.tar.gz" else echo "Failed to get ${AUTOCONF}.tar.gz. Aborting install!" exit 0 fi fi fi

if [ -a ${SRCDIR}/${SSH2}.tgz ]; then echo "Skipping wget of ${SSH2}.tgz" else wget $WGETOPT http://pecl.php.net/get/${SSH2}.tgz # If primary mirror fails, use the alternative mirror. if [ -a ${SRCDIR}/${SSH2}.tgz ]; then echo "Got ${SSH2}.tgz" else echo "Failed to get ${SSH2}.tgz. Aborting install!" exit 0 fi fi

cd ${SRCDIR} echo "Extracting ${LIBSSH2}..." tar xzf ${SRCDIR}/${LIBSSH2}.tar.gz > /dev/null echo "Done."
 * 1) Extract the src files into the src directory.

cd ${SRCDIR} echo "Extracting ${AUTOCONF}..." tar xzf ${SRCDIR}/${AUTOCONF}.tar.gz > /dev/null

echo "Extracting ${SSH2}..." tar xzf ${SRCDIR}/${SSH2}.tgz > /dev/null echo "Done."


 * 1) Compile

cd ${SRCDIR}/${AUTOCONF} ./configure --prefix=${PREFIXDIR} make install
 * 1) AUTOCONF

cd ${SRCDIR}/${LIBSSH2} ./configure ${LIBSSH2FEATURES} make all install
 * 1) LIBSSH2

cd ${SRCDIR}/${SSH2} $PHP_PREFIX/phpize ./configure ${SSH2FEATURES} make
 * 1) SSH2

sleep 2s cd ${SRCDIR} && clear
 * 1) Post install clean-up.

echo "Installation completed! Your php extension should be in ${SSH2}/modules" `date +%r`
 * 1) End of Install


 * EOF