When using lftp over FTPS, you may be able to log in successfully but still fail when transferring files:
Lftp put: Access failed: 521 Data connections must be encrypted.
This happens because lftp needs an extra setting to protect the data connection properly over FTPS.
Create an rc file under the current user’s .lftp directory, for example:
1 | /root/.lftp/rc |
Add this line:
1 | set ftp:ssl-protect-data true |
You can also add the same setting directly in your command or script:
1 | lftp -u user ftp.test.com -e "set ftp:ssl-protect-data true;put -a file;exit" |