7

I want to sync a remote folder with a local folder using lftp.

When I installed the first time "lftp" and I created this script:

#!/bin/bash

#get username and password
USER=...        #Your username
PASS=...        #Your password
HOST="..."         #Keep just the address

echo Sync started ...

LCD="/var/www/myfolder/app"    #Your local directory
RCD="/app"                   #FTP server directory

lftp -f "
open $HOST
user $USER $PASS
lcd $LCD
mirror --continue --reverse --delete --no-symlinks --exclude .gitkeep --exclude .gitignore --exclude .bower.json --verbose $LCD $RCD
bye
"

Everything worked like a charm.

After that, I tried to compile lftp with SSL support (I downloaded the source, compiled in a deb package and installed it) to sync to an SSL FTP server. I did not figure out, but I did not need any more, so I wanted to come back to the start situation.

Now, even if I remove lftp and I install it again without SSL, when I execute the script I get this message:

mkdir `/app' [FEAT negotiation...]

The command just goes in timeout (I saw it with the debug). How can I solve it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Giacomo M
  • 4,450
  • 7
  • 28
  • 57

2 Answers2

30

I have faced the exact same problem. It was resolved by explicitly providing a protocol prefix 'sftp' in the connection string. By default lftp uses 'ftp' as a protocol.

HOST="sftp://<hostname>" # <-- make sure that you have specified the protocol here

lftp <<EOF 
set ssl:verify-certificate no  
set sftp:auto-confirm yes
open $HOST -p $PORT -u $USER,$PASSWORD
mirror $RCD $LCD
EOF
4

I've turned FEAT features off, and it worked like a charm. Just use this command before opening a connection:

set ftp:use-feat false
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sequielo
  • 1,541
  • 1
  • 18
  • 27
  • `man lftp` (the man page) includes this tip on setting features in config files: ```On startup, lftp executes /etc/lftp.conf and then ~/.lftprc and ~/.lftp/rc (or ~/.config/lftp/rc if ~/.lftp does not exist). You can place aliases and `set' commands there. Some people prefer to see full protocol debug, use `debug' to turn the debug on. Use `debug 3' to see only greeting messages and error messages.``` – mmell Sep 04 '19 at 23:07
  • 1
    What are "FEAT features"? Can you extend your answer (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today)? – Peter Mortensen May 18 '21 at 00:34