0

I am using phpseclib 2.0 on my site, installed using composer. I wrote a php function which basically connects to a remote server via SFTP, and download files within a predefined directory. This function is called via CRON using cURL and have been working fine. Last week, it stopped working. I enabled logging and this is what I get.

Severity: User Notice
Message:  Error reading channel data
Filename: Net/SSH2.php
Line Number: 3579

Severity: User Notice
Message:  Connection closed prematurely
Filename: Net/SSH2.php
Line Number: 3025

Severity: User Notice
Message:  Connection closed by server
Filename: Net/SSH2.php
Line Number: 3373

Severity: User Notice
Message:  Expected SSH_FXP_VERSION
Filename: Net/SFTP.php
Line Number: 471

When I checked the table used to store the contents of the downloaded files, none was updated.

The weird thing is that if I were to execute the exact command from the CRON, everything works fine and the table is updated. I have check CROND logs and I can confirm that it is using the same permission as its the same user, ie. root. Anyone have any insight on this issue as I have no idea. I have changed from using cURL to using httpie, but the same result. Works when executed manually on the command line but failed when executed by CRON.

The only server change I did was to upgrade my PHP from version 5.6 to version 7.0. Could that be the cause? If anyone has a solution or any insight on how I can solve this, that would be greatly appreciated. Thanks in advance.

asyadiqin
  • 1,637
  • 3
  • 19
  • 25
  • Can you post the SSH logs? You can get them by doing `define('NET_SSH2_LOGGING', 2)` and then doing `echo $sftp->getLog()`. – neubert Jun 25 '17 at 01:07

1 Answers1

0

PHP 7 is more strickt to SSL certificates.

Check if the see if the server you're connencting to is giving a proper certificate. or if you can have php ignore the invalid certificate. (less prefered to setting it up properly of course)

--

however this does not explain why you can run the script manually. Only thing I can think of now: is some cert. in the search path when logging in as a user?

Ivo P
  • 1,722
  • 1
  • 7
  • 18