1

I trying to install the php_ssh2.dll extension on a

  • Windows 2012 Rc2 64bit System
  • Apache 2.4.26
  • php 5.6.31

for ssh2_connect() ... i want to open a sftp connection

1.) I toke the libssh2.dll into /System32 and /syswow64 folder

2.) the php_ssh2.dll and php_ssh2.pdb into /xampp/php/ext folder

3.) modified php.ini (add extension=php_ssh2.dll)

4.) restarted Apache

I start my example script an result:

Fatal error: Call to undefined function ssh2_connect()

Now, I'm not sure how I can solve this issue, maybe someone has any idea?

Jigar Shah
  • 6,143
  • 2
  • 28
  • 41
Korty
  • 309
  • 2
  • 8
  • 19
  • 1
    Possible duplicate of [PHP Install SSH2 on Windows machine](https://stackoverflow.com/questions/15134421/php-install-ssh2-on-windows-machine) – Chris Sep 26 '17 at 12:06
  • yes, I tried this also `C:\> regsvr32 libssh2.dll` but I got a error message "the module "libssh2.dll" failed to load" – Korty Sep 26 '17 at 12:16
  • The appache Error Log has an entry about: "PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\xampp\\php\\ext\\php_ssh2.dll' - %1 is not a valid Win32 application.\r\n in Unknown on line 0" – Korty Sep 26 '17 at 12:16
  • Try this: https://phpfashion.com/php-ssh2-dll-for-php-5-6-and-7-0 – relipse Feb 04 '19 at 19:09

1 Answers1

3

I tested a lot the last few hours. Update to php 7.1, used some other versions of php_ssh2.dll / libssh2.dll, tried to install the dll on Windows by Powershell (regsvr32.exe) ... nothing works with ssh2_connect($ftp_server, 22);

!But I found a other solution by using curl()

here is my example (it works!)

 <?php

 $ftp_server = 'xxx'; $ftp_user_name = 'xxx'; $ftp_user_pass = 'xxx';

 $c = curl_init("sftp://$ftp_user_name:$ftp_user_pass@$ftp_server/folder/file.xxx");
 curl_setopt($c, CURLOPT_PROTOCOLS, CURLPROTO_SFTP); $data =
 curl_exec($c); curl_close($c);

 if ($data === false){echo 'err';}else{echo 'done';}

?>
Korty
  • 309
  • 2
  • 8
  • 19