Do you often access your ftp site to make some simple changes or to share some documents that you wish to be accessible from anywhere?
You can make access to your ftp resource easier with the CurlFtpFS Linux utility. This fantastic utility allows you to mount your ftp site to any directory within your Linux filesystem.
In this guide, we’ll go over the installation of CurlFtpFS on major Linux distros, then cover the step by step instructions to configure it.
In this tutorial you will learn:
- How to install CurlFtpFS on major Linux distros
- How to mount remote FTP directory using CurlFtpFS
- How to mount an FTP directory automatically with
/etc/fstab
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | CurlFtpFS |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install CurlFtpFS
Before proceeding with the steps below, you’ll need to install the CurlFtpFS software on your system. It can be easily installed using your system’s package manager by executing the appropriate command below.
To install CurlFtpFS on Ubuntu, Debian, and Linux Mint:
$ sudo apt install curlftpfs
To install CurlFtpFS on CentOS, Fedora, AlmaLinux, and Red Hat:
$ sudo dnf install curlftpfs
To install CurlFtpFS on Arch Linux and Manjaro:
$ sudo pacman -S curlftpfs
Mount ftp directory
- After CurlFtpFS has been installed, create a directory where you would like to mount the remote FTP server.
# mkdir /mnt/my_ftp
- Next, use curlftpfs to mount your remote ftp site by using the following command syntax.
# curlftpfs ftp-user:ftp-pass@my-ftp-location.local /mnt/my_ftp/
Of course, replace
ftp-user
with your username,ftp-pass
with your password, andftp-location
with the remote server’s IP address or hostname. - On most Linux systems you can mount ftp using curlftpfs as root and this allows only root user to access ftp mount. No other users are allowed since by default only users that mount have access to mount directory. When mounting ftp as a non-root user you may get a following error message:
fuse: failed to open /dev/fuse: Permission denied
Rather that changing permissions of
/dev/fuse
you can allow other users to access ftp mount directory with an curlftpfs’s optionallow_other
. The command will look similar to the one below:# curlftpfs -o allow_other ftp-user:ftp-pass@my-ftp-location.local /mnt/my_ftp/
FTP uses unencrypted passwords so anyone can intercept your password without much effort. Therefore use curlftpfs in combination with SSL certificates if your are not mounting some local LAN ftp server.
Mount ftp with curlftpfs using /etc/fstab
- Since we do not want to put any passwords in the
/etc/fstab
file, we will first create a/root/.netrc
file with a ftp username and password using this format:machine my-ftp-location.local login ftp-user password ftp-pass
- Next, change permissions of this file to 600:
# chmod 600 /root/.netrc
- Check uid and gid of your non-root user. This user will have access to ftp mount directory:
$ id
- In the next step add the following line to your
/etc/fstab
file ( change credentials for your ftp user ):curlftpfs#my-ftp-location.local /mnt/my_ftp fuse allow_other,uid=1000,gid=1000,umask=0022 0 0
- Now mount the remote FTP directory with:
$ mount -a
Closing Thoughts
In this guide, we saw how to mount remote FTP directories on Linux through the CurlFtpFS utility. This makes access to FTP servers much more convenient, since there’s no need to use an FTP client or authenticate every time. The mounting is seamless thanks to CurlFtpFS, and we can access the FTP directory as if it were a part of our physical computer.