I have a php system running on AWS and a class that upload a xlsx file on external server using shh2 and sftp. This code worked fine until last upgrade of aws package openssh-clients-6.6.1p1-31.62 and openssh-server-6.6.1p1-31.62 by this time I have a segfault during fopen. Fopen create a file on external server. Here the code:
$stream = @fopen("ssh2.sftp://$this->sftp$remote_file", 'w');
Then I use $stream to write the content, but the code stop on fopen bacause a segfault. I don't find anything about this problem, I think the problem is the new upgrade of opnessh, because the php code isn't changed. Any idea?
Found the answer here on StackOverflow: https://stackoverflow.com/a/40972584/2520795
It seems since this PHP update, you have to surround your host part (result of ssh2_sftp()
) with intval()
:
$handle = opendir("ssh2.sftp://".intval($sftp)."/path/to/directory");
In my case there was a fopen
instead of an opendir
, but the solution is the same.