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.