SSH2 PHP Extension

Beamer180 picture Beamer180 · Mar 27, 2012 · Viewed 8.3k times · Source

I have been trying for a while to get the SSH 2 extension for php installed on my CentOS 5.6 x64 server. I started the server from scratch and here are the steps I have taken

  1. install and configure APF
  2. install apache
  3. install php
  4. install mysql
  5. add epel repository
  6. install php-pear so I can use pecl
  7. run yum install libssh2-devel
  8. run pecl install ssh2-beta
  9. echo extension=ssh2.so>>/etc/php.ini (There were a few extra things in there such as installing phpMyadmin and wordpress)

After this I run php -m to see the php modules and ssh2 is not listed. I have been searching forever for tutorials and have found a few but from what I can see I have done everything correctly. Can anyone see where I am going wrong. I can provide any config files you may need. Also I have hear about phpseclib and was wondering if this would be an easier/better route? Any help would be greatly appreciated!

Answer

neubert picture neubert · Mar 27, 2012

You could maybe try phpseclib, a pure PHP SFTP implementation, instead. eg.

<?php
include('Net/SFTP.php');

$sftp = new Net_SFTP('www.domain.tld');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}

echo $sftp->pwd() . "\r\n";
$sftp->put('filename.ext', 'hello, world!');
print_r($sftp->nlist());
?>