drmrbrewer
drmrbrewer

Reputation: 13009

lftp hangs on "connecting"

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.

Upvotes: 2

Views: 18017

Answers (3)

alexxmed
alexxmed

Reputation: 81

This can also be caused by mismatches or permissions issues in ~/.ssh/known_hosts and ~./ssh/authorized_keys.

After correcting the conflict with the port forwarding rule in the router, this happened again for one of the users. I fixed it by copying my (working) ~/.ssh/authorized_keys and ~/.ssh/known_hosts over hers and setting the permissions.

Upvotes: 1

alexxmed
alexxmed

Reputation: 81

I had this problem after upgrading Ubuntu to 16.04 to make use of TLS 1.2. The first command issued, whether a cd or an ls would result in [Connecting...] which would hang.

It turned out that their Comcast Router had a port forwarding rule for incoming tcp port 21 (21 is ftp) to a holter monitor server. I disabled that rule and the problem went away instantly.

Upvotes: 1

Anton
Anton

Reputation: 970

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
!

Upvotes: 6

Related Questions