Today there is nothing to say to everyone about Linux installation SSH2 expansion, want to install under the WinDOS but PHP expansion can not find, tears running ...
So I can only do experiments in Linux, but all the same,,,,
Download Address
wget http://www.libssh2.org/download/libssh2-1.4.2.tar.gz
wget http://pecl.php.net/get/ssh2-0.12.tgz
Install LIBSSH2 before installing SS2
# TAR-ZXVF Libssh2-1.4.2.tar.gz
# CD libssh2-1.4.2
#./configure--PREFIX=/USR/LOCAL/LIBSSH2
# Make && make install
For the above installation LIBSSH2, you need to remember LIBSSH2 's installation directory, because it will be used when installing SSH2.
# TAR-ZXVF Ssh2-0.12.tgz
# CD ssh2-0.12
# phpize
#./configure--prefix=/usr/local/ssh2--with-ssh2=/usr/local/libssh2
# make
SSH installation
# TAR-ZXVF Ssh2-0.12.tgz
# CD ssh2-0.12
# phpize
#./configure--prefix=/usr/local/ssh2--with-ssh2=/usr/local/libssh2--with-php-config=/usr/local/php/bin/ Php-config
# Make && make install
SSH2 expands in/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/directory after Setup completes
Modify php.ini file Join
Extension=ssh2.so
Ah haha join expansion success
<?php
$user = "root";//remote User name
$pass = "123456";//Remote password
$connection =ssh2_connect (' 192.168.1.46 ', 22);
Ssh2_auth_password ($connection, $user, $pass);
$cmd = "ps aux";//Command
$ret =ssh2_exec ($connection, $cmd);
Stream_set_blocking ($ret, true);
Echo (Stream_get_contents ($ret));
Print_r (Phpinfo ());
?>