lftp hangs on "connecting"

drmrbrewer picture drmrbrewer · Jul 11, 2016 · Viewed 8k times · Source

I use lftp to transfer files from my Cloud 9 IDE to a remote host. Recently, it seems to have stopped working. I've raised this with the host, and they think it's working OK. Indeed, I can connect to the ftp host via FileZilla, and via a simple browser. I've raised it with Cloud 9, but no luck either.

I'm transferring a file using the following from the command line:

lftp -e "debug; set ssl:verify-certificate no; put ./res/test.txt -o test.txt; bye" -u abcd,xyz ftp.example.com

(the set ssl:verify-certificate no was an addition from a while ago, to overcome a similar connection problem that suddenly appeared... I've tried without it too... same result)

What I'm finding in C9 is that is forever trying connect, with:

---- Connecting to ftp.example.com (xx.xxx.xx.xxx) port 21
**** Socket error (Connection timed out) - reconnecting
---- Closing control socket
---- Connecting to ftp.example.com (xx.xxx.xx.xxx) port 21
**** Socket error (Connection timed out) - reconnecting
---- Closing control socket
---- Connecting to ftp.example.com (xx.xxx.xx.xxx) port 21

Difficult to offer any assistance, probably, but does anyone have any ideas at least to help me diagnose? Any additional options to try?

Thanks.

Answer

Anton picture Anton · Mar 11, 2019

In my case lftp doesn't instruct ssh to use "password authentication" explicitly and it stuck waiting for a password from a keyboard

<--- debug1: Authentications that can continue: keyboard-interactive,password
<--- debug1: Next authentication method: keyboard-interactive 
<--- Password authentication

after setting sftp:connect-program to "ssh -oPreferredAuthentications=password -a -x" I got rid of the issue.

lftp << !
  set sftp:connect-program "ssh -oPreferredAuthentications=password -a -x"
  open -u $USER --env-password $PROTOCOL://$HOST
  mirror -vvv -c --only-missing -P 600 $SRC_FOLDER /dbfs/mnt/$HOST/$DST_FOLDER
!

if you still have the issue then you can enable debug and see what is going wrong by passing -v to ssh and -d to open

lftp << !
  set sftp:connect-program "ssh -a -x -v"
  open -d -u $USER --env-password $PROTOCOL://$HOST
  ls
!