phpseclib always produces login failed

54
February 11, 2019, at 3:00 PM

I'm not sure if this is me doing something wrong or whether the server just doesn't support phpseclib or what, but I am trying to connect to an FTP server that will only accept secure FTP connections, and only from certain IP addresses. Now I know that the FTP server accepts a connection from my VPS server as I have remotely connected into my VPS via SSH and manually connected to the FTP server from the command line successfully.

However when I try the following with phpseclib it always hits the exit point.

set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include 'Net/SFTP.php';
$sftp = new NET_SFTP('***');
if(!$sftp->login('***', '***')) {
    $sftp->getSFTPErrors();
    exit('Login Failed'); // <-- Code always gets to this point
}
echo $sftp->pwd();

I am unsure on how to even begin debugging this problem. I have asked a question on their forum as well to try and get help. I have tried to enable logging with define('NET_SFTP_LOGGING', NET_SFTP_LOG_COMPLEX); and then output echo $sftp->getSFTPLog(); just above the exit, but that doesn't output anything.

On the page I have just Login Failed, so I'm not getting any errors from $sftp->getSFTPErrors();.

I am completely new to using a secure FTP connection in PHP and don't know what I am doing wrong. Can someone please help me debug the issue?

Answer 1

The way you're using it it's clear that you don't see any errors. $sftp->getLastSFTPError() returns a string and $sftp->getSFTPErrors() returns an array, and that's what you have to echo in order to see what's wrong.

Try

print_r($sftp->getSFTPErrors());
READ ALSO
PHP and GEOHASH: how to use GeoHash to calculate distance between 2 points?

PHP and GEOHASH: how to use GeoHash to calculate distance between 2 points?

I understood that GEOHASH allows to hash (lat,long) into a String

77
Edit html table row and update It into mysql table using php

Edit html table row and update It into mysql table using php

I have created update button on my every row in table dynamically using JQuery that successfully editing the table but i don't know how to call php function for updating the database,

32
Get count posts of model Post Laravel

Get count posts of model Post Laravel

I have a model Post, in this model I created accesor:

51
How can i use dropdown in table &lt;td&gt; tag

How can i use dropdown in table <td> tag

I have an Inline editable Table which updates the Mysql table for the team group column I want to use the drop-down list

61