I've tried several different methods of connecting to an SFTP server and in all cases I get a 500 error either when I connect or when I try to upload a file.
I've tried connecting to two different servers, getting the same results each time. I am however able to connect to both servers using a GUI interface client, no problem.
Using SSH2_connect:
//<!--************************************************************************-->
//<!--*** Connect using ssh2
//<!--************************************************************************-->
$conn = ssh2_connect($ftp_host, 22);
ssh2_auth_password($conn, $ftp_username, $ftp_password);
//<!--************************************************************************-->
//<!--*** Send the file
//<!--************************************************************************-->
ssh2_scp_send($conn, $localfile, $remote_file);
The connect call causes a 500 error.
I also tried using PHPSecLib, as recommended by so many people on StackExchange, but I run into the same problem.
include("common/PHP SFTP/Net/SFTP.php");
//<!--************************************************************************-->
//<!--*** Connect using sftp
//<!--************************************************************************-->
$sftp = new Net_SFTP($ftp_host);
//<!--************************************************************************-->
//<!--*** Log into ftp server
//<!--************************************************************************-->
if ($sftp->login($ftp_username, $ftp_password)) {
//<!--************************************************************************-->
//<!--*** Send local file via ftp
//<!--************************************************************************-->
if(!$sftp->put($remote_file, $localfile)){
errorLog(1,"DEBUG","eft transfer","Fail");
}
}else{
errorLog(1,"DEBUG","sftp connection","Fail");
}
//<!--************************************************************************-->
//<!--*** Close the connection
//<!--************************************************************************-->
ftp_close($ftp_connection);
In this case creating a new Net_SFTP object causes no problems so it's not a pathing issue to the included PHPSecLib file, but as soon as I try to login to the ftp server it falls over with a 500 error.
Using phpinfo() I've confirmed that I have OpenSSL enabled on the server. SFTP protocol is also enabled. SSH2 DLL is also installed and enabled.
I don't know what else to look for.
These are the errors in my log file
[25-Sep-2017 11:53:15 America/New_York] PHP Notice: Undefined index: pagedate in C:\inetpub\wwwroot\TimeSavr\Refresh\common\initialize.php on line 111
[25-Sep-2017 09:53:15 America/Edmonton] PHP Notice: Undefined variable: content in C:\inetpub\wwwroot\TimeSavr\Refresh\common\common.php on line 8
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(Math/BigInteger.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 891
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(): Failed opening 'Math/BigInteger.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 891
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(Crypt/Random.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 895
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(): Failed opening 'Crypt/Random.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 895
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(Crypt/Hash.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 899
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(): Failed opening 'Crypt/Hash.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 899
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(Crypt/Base.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 904
[25-Sep-2017 09:53:15 America/Edmonton] PHP Warning: include_once(): Failed opening 'Crypt/Base.php' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 904
[25-Sep-2017 09:53:16 America/Edmonton] PHP Fatal error: Call to undefined function phpseclib_resolve_include_path() in C:\inetpub\wwwroot\TimeSavr\Refresh\common\PHP SFTP\Net\SSH2.php on line 1243