#!/bin/sh
# LFTP.sh
#
# Created by David Kittell on 9/26/2018.
#
if ! rpm -qa | grep -qw lftp; then
echo "Installing lftp"
yum install lftp -y
else
echo "lftp is already installed"
fi
# lftp profile creation example
lftp -c "bookmark add SiteName ftp://user:password@sitename.com/path"
#lftp -c "bookmark add SiteName ftp://user:password@sitename.com:2121/path" # For a different FTP port
# If you are using SFTP it's better to use this line
#lftp -c "bookmark add SiteName sftp://user:password@sitename.com/path"
#lftp -c "bookmark add SiteName sftp://user:password@sitename.com:2121/path" # For a different FTP port
# lftp upload file
lftp -c "open SiteName && lcd MyLocalDir && mput ./"*
If you run into issues with SSL certificate verification the below should help.
NOTE: Even though we backup the original configuration, test this on a development server first.
# Disable SSL Verification - Start # If you are running into problems with SSL certification verification sudo cp /etc/lftp.conf /etc/lftp.conf.original_`date +%Y_%m_%d_%H.%M.%S` sudo sed -i "/^\s*#/d;s/\s*#[^\"']*$//" /etc/lftp.conf && sudo sed -i '/^\s*$/d' /etc/lftp.conf echo "set ssl:verify-certificate no" | sudo tee -a /etc/lftp.conf # Disable SSL Verification - Stop
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.