ftp · linux

ftp: send files to a specific directory in a ftp server using lftp via command line

So, you have access to a given FTP server with the appropriated user/password and now you want to push some files to it directly via command line, using a bash scrip, via your CI service, etc. How could you do this using lftp? Easy!

The first step is to install lftp in your environment, you just need to execute the following command line:


lftp -c "open -u $FTP_USERNAME,$FTP_PASSWORD $FTP_SERVER; set ssl-allow yes; set passive-mode yes; set ssl:verify-certificate no; put -O $FTP_DIRECTORY "

You can also do a mirror by using:


lftp -c "open -u $FTP_USERNAME,$FTP_PASSWORD $FTP_SERVER; set ssl-allow yes; set passive-mode yes; set ssl:verify-certificate no; mirror -R $LOCAL_DIRECTORY $FTP_DIRECTORY"

🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s