ArchLinux 2018.10.01: Install curlftpfs for FTP client

This article will describe installing curlftpfs for FTP client.

1 Install curlftpfs

Install curlftpfs package.

$ sudo pacman -Sy --noconfirm curlftpfs

2 Mount FTP with curlftpfs

Mount FTP with curlftpfs to mnt directory.

$ mkdir mnt
$ curlftpfs -o user=${FTP_USERNAME} "${FTP_SERVER}" mnt
Enter host password for user '${FTP_USERNME}':

You can set password with user=<username>:<password>.

$ curlftpfs -o user=${FTP_USERNAME}:${FTP_PASSWORD} \
  "${FTP_SERVER}" mnt

The password in ~/.netrc will be used with user=<username>:.

$ cat <<EOF > ~/.netrc
machine ${FTP_SERVER}
password ${FTP_PASSWORD}
$ chmod 600 ~/.netrc
$ curlftpfs -o user=${FTP_USERNAME}: "${FTP_SERVER}" mnt

If not specifying user, you will connect as anonymous user.

$ curlftpfs "${FTP_SERVER}" mnt

The allow_other allows access from other user. The allow_root allows access from root user. If not specifying allow_other and allow_root, mount point can be accessed by only user which runs mount.

$ curlftpfs -o user=${FTP_USERNAME},allow_other \
  "${FTP_SERVER}" mnt

3 Mount FTP on boot

Add mount entry to /etc/fstab. For avoiding mounting FTP before network initialization, you need to add _netdev option. For making x-systemd.automount to mount FTP, you need to add x-systemd.automount to option.

$ OPT=_netdev,x-systemd.automount,allow_other
$ cat <<EOF | sudo tee -a /etc/fstab
curlftpfs#${FTP_USERNAME}:${FTP_PASSWORD}@${FTP_SERVER} /mnt fuse ${OPT} 0 0

Creating .netrc in /root can omit password.

$ cat <<EOF | sudo tee /root/.netrc
machine ${FTP_SERVER}
password ${FTP_PASSWORD}
$ sudo chmod 600 /root/.netrc
$ echo "curlftpfs#${FTP_USERNAME}:@${FTP_SERVER} /mnt fuse ${OPT} 0 0" | \
    sudo tee -a /etc/fstab