Contents...
Recently one user asked me one question, How I can transfer one latest file from ftp server and I also want to automate this task using shell script to download latest file from ftp server is this possible?
Answer: It is difficult to automate this task using shell or Perl script in normal ftp client. We can use curlftps in Linux to mount our ftp server share data on local system. Than after mounting directory we can run script to automate this task.
Curlftps Features:
- It support SSL
- Connect through tunnelling HTTP proxies
- Reconnect automatically if server went time out
- Mount same as Samba and NFS share
- Automate ftp transfers
Now Follow the below steps to install and configure curlftps.
Step #1: Install Curlftps package on Linux
On CentOS/Redhat/Fedora System
# yum install curlftps
Or If above command not work install it from rpm package.
# rpm -ivh fuse-curlftpfs-0.9.1-1.el5.rf.i386.rpm
On Ubuntu/Debian System
$ apt-get install curlftpfs
Step #2: After package installed create mount point and mount ftp server data using curlftps command, to do this we have ftp username and password. In my example:
FTP User : sagar FTP Password : pass@123 FTP Server : ftp.looklinux.com Mount Point : /ftpmount
Now we will create the mount point and mount ftp account data on it.
# mkdir /ftpmount # curlftpfs -o allow_other sagar:pass@[email protected] /ftpmount
Above command is self explanatory and allow_others option is used to Allow Access to other users. By default the mount point is only accessible to the user who mounted it and not even to root user.
Step #3: Now test our set-up
Follow the below command to see the ftp data.
# cd /ftpmount # ls
You will get some output like below.
2017-03-02.txt mytestfile.txt common data
And with df -hs command output.
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 23G 5.4G 17G 25% /
none 1.5G 300K 1.5G 1% /dev
none 1.5G 2.9M 1.5G 1% /dev/shm
none 1.5G 128K 1.5G 1% /var/run
none 1.5G 0 1.5G 0% /var/lock
/dev/sda7 404G 88G 296G 23% /data
/dev/sda5 23G 10G 12G 46% /home
/dev/sr0 3.2G 3.2G 0 100% /media/My Disc
curlftpfs#ftp://sagar:pass@[email protected]/ 6.5T 0 6.5T 0% /ftpmount
If everything looks good mount it permanently.
Step #4: Mount curlftps data permanently by editing “/etc/fstab” file.
# vim /etc/fstab
Add below line at the end of file.
curlftpfs#ftp://sagar:pass@[email protected]/ /ftpmount fuse defaults 0 0
Above we are mounting user sagar data which is on ftp.looklinux.com server on to /ftpmount using fuse file system with its default settings.
Step #5: Un-mount curlftps data.
Follow the below command to unmount it.
# umount /ftpmount
That’s it.
I hope this article will help you to mount ftp share data on your local Linux system. If you have any queries and problem please comment in comment section.
Thanks:)
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
I saw a lot of website but I think this one contains something special in it.
Thanks.
Thank you sir. This article is great!
Thanks Amir for visiting LookLinux.
Great!. Thanks so much, linux is powerful.
Um, this is pretty toxic and there isn’t a warning in sight.
You’re advising people to jam the ftp user’s password into /etc/fstab which is readable by all on the local machine.
Secondly, it’s FTP, so it’s inherently insecure unless using a tunnel.
OK, so people cut and paste at their own peril, but you could alert them to the pitfalls.
Very nice article, totally what I wanted to find.