Monday, 27 July 2009

curlftpfs - mounting ftp sites using FUSE

curlftpfs is a neat package that allows one to mount an FTP host onto a local filesystem. It uses the libcurl package for all the transfer operations and FUSE (filesystem in userspace) for the filesystem glue.

It's also fairly straight-forward to use. To install on a Ubuntu system, use:

apt-get install curlftpfs

Now let's mount the UKC FTP mirror service onto a mountpoint: /mnt/ukcmirror

sudo mkdir /mnt/ukcmirror
sudo curlftpfs -o allow_other /mnt/ukcmirror

Note that the allow_other flag allows non-root users to access the mount. To unmount, use:

sudo umount /mnt/ukcmirror

However, this will expose your username, password pair as it's shown up using ps aux, so we need to hide the password using the following method:

Edit the file /root/.netrc as root and add in one's username/password details:

login anonymous
password anonymous

..and change the permissions on this file:

sudo chmod o-rw /root/.netrc

Now you can mount it using:

sudo curlftpfs -o allow_other /mnt/ukcmirror

Alternatively, you may like to mount this by putting the details into /etc/fstab. Add the following one line of text to /etc/fstab: /mnt/ukcmirror fuse allow_other,rw,user,noauto 0 0

And now you can mount it using:

sudo mount /mnt/ukcmirror

This is also useful for some awkward NAS boxes, such as the Freecom 500 which seems to have a poor SMB implementation, so one has to resort to using FTP access.

No comments:

Post a comment