Deru Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

How to install SSH2 for PHP Shell?

Views: 1112
Votes: 0
Posted: 04 Sep, 2009
by: Kanchan C.
Updated: 08 Sep, 2009
by: Joseph S.
Step : 1
install  openssl if it's not already there in the server by the following way-
#yum install openssl

Step : 2
install  libssh2 by the following way-

#wget http://voxel.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.18.tar.gz
#tar -zxvf libssh2-0.18.tar.gz
#cd libssh2-0.18
#./configure
#make
#make install



Step : 3
Now install ssh2 php module by the following way-

#wget http://pecl.php.net/get/ssh2-0.10.tgz
#tar -xzf ssh2-0.10.tgz
#cd ssh2-0.10
#vi ssh2.c

(Search for the line:
#if LIBSSH2_APINO < 200412301450
and replace it with:
#if LIBSSH2_VERSION_NUM < 0x001000
)
#phpize && ./configure -with-ssh2 && make
#make test
#make install


Step : 4
Link the ssh2 library with php.

copy ssh2-0.10/.libs/ssh2.so to php extension_dir mentioned at php.ini

Add the following line to php.ini-
 extension=ssh2.so

It's done.

Now use a simple function to test it.
<?php
$connection = ssh2_connect('servername', 22);
ssh2_auth_password($connection, 'username', 'password');

if(ssh2_sftp($connection))
{
echo "connect";
}else
{
echo "not connected";
}
?>



That's all :)
Others in this Category
document CGI: debugging Internal Server Error
document Running php4 and php5 together in server
document Configuring mod_jk for apache in Cpanel server ?
document How do you use different characterset using .htaccess?
document Useful Exim Commands.
document How you replace your php fopen function with curl?
document How to use curl to get the file contents
document Album access issue in Gallery
document How to install APC (Alternative PHP Cache)
document Steps to enable SMTP Authentication - in different email clients



RSS