OpenSUSE Leap 15: Install curlftpfs for FTP client

This article will describe installing curlftpfs for FTP client.

1 Install curlftpfs

Install curlftpfs package.

> sudo zypper -n in curlftpfs

2 Mount FTP with curlftpfs

Mount FTP with curlftpfs to mnt directory.

> FTP_SERVER=$(hostname)-ftp-server.hiroom2.com
> FTP_USERNAME=guest
> FTP_PASSWORD=guest
> 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}
login ${FTP_USERNAME}
password ${FTP_PASSWORD}
EOF
> 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
EOF

Creating .netrc in /root can omit password.

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