I am trying to connect an SFTP server using phpseclib, but I get the following error
"Notice: Connection closed prematurely in \phpseclib\Net\SSH2.php on line 3396" and never get success message.
Login details are working fine on FileZilla.
Below is my code
use phpseclib\Crypt\RSA;
use phpseclib\Net\SSH2;
define('NET_SSH2_LOGGING', SSH2::LOG_COMPLEX);
$key = new RSA();
$key->setPassword('ppk file password');
$key->loadKey(file_get_contents('ppk file path'));
$ssh2 = new SSH2('domain:port');
if (!$ssh2->login('sftp user', $key)) {
$log = $ssh2->getLog();
echo $log;
exit('Login Failed');
}else{
exit('Success');
}
Any help why I am getting an error is much appreciated.