1

I am trying to use php_ssh2 to send commands via sftp to a raspberry pi from a windows server with xampp as web server and PHP 5.5. I could not make it work although I followed the procedure at PHP Install SSH2 on Windows machine. Maybe there are some updates for Windows 8. When I try to register libssh2.dll i get an error (it is not a valid .dll) although I downloaded the latest version. If I execute php -i I get this error: "PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_ssh2.dll' - it is not a valid Win-32 Application" The operation system is Windows 8 64bit. Any suggestion?

Community
  • 1
  • 1

3 Answers3

1

My recommendation: use phpseclib, a pure PHP SSH2 implementation. eg.

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

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

echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>

It has a number of advantages over libssh2:

  • more portable.
  • easier to use.
  • faster
  • better public key support
  • etc.
  • Thanks for the suggestion. Do you know how to set it into a zf2 project? – Daniele Protti Feb 07 '15 at 21:25
  • I updated composer.json in my root folder: "autoload": { "psr-0": {"phpseclib\\": "vendor/phpseclib/"} } ; i downloaded the package and saved into vendore/phpseclib. then I called phpseclib in a controller in Application. "use phpseclib" .... and then "$ssh = new Net_SSH2(ip)" but i get a Fatal error "Class not found" – Daniele Protti Feb 09 '15 at 23:13
0

First you need to find

Architecture - 32 bit or 64 bit or 86 bit
compiler version - VC9 or VC11 or VC14
Thread safe or Non thread safe

This can be find by open phpinfo or echo phpinfo() in any php file. Then search for Compiler,Architecture and Thread Safety

Then go to http://windows.php.net/download/ and download right Releases. Replace needed file then restart web server

Manik Thakur
  • 294
  • 2
  • 15
-1

download library for x64 system, here >

ssh2 library 0.12 for PHP 5.5 - Non Thread Safe (NTS) x64

ssh2 library 0.12 for PHP 5.5 - Thread Safe (TS) x64