Updated : Oct 08, 2019 in Uncategorized

FTPS on command line using LFTP

# In Debian/Ubuntu, install LFTP
apt-get install lftp

# Create the configuration file in home directory of the user
# eg. admin user will be running the program:
cd /home/admin
touch .lftprc

(Content)
set ftp:ssl-auth TLS
set ftp:ssl-force true
set ftp:ssl-protect-list yes
set ftp:ssl-protect-data yes
set ftp:ssl-protect-fxp yes
set ssl:verify-certificate no

Command line to upload 2 files: software.txt and software2.txt

cd /DATA/files/
lftp user:PASSWORD@servername <<EOF
put
software.txt
put
software2.txt
EOF
OR (LFTP command in one line)
cd /DATA/files/
echo "put software.txt ; put software2.txt ;" | lftp \
user:PASSWORD@servername
  
OR (another variation of on the same line)
cd /DATA/files/
echo "exit"|lftp -e 'put software.txt;put software2.txt;' \
user:PASSWORD@servername

DIRECTORIES

Here we transfer recursively 2 directories(dir1 & dir2):
echo "mirror -R dir1; mirror -R dir2;" |lftp \
user:PASSWORD@servername
OR (with different User & Password format)
echo "exit" | lftp -e 'mirror -R dir1; mirror -R dir2;' \
-u user,PASSWORD servername

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: