For this setup, i'm using Ubuntu 16.04 running on a Raspberry Pi 3. The instructions should work correctly in Debian and Raspbian too -- in fact, you will probably have luck using these instructions on any Linux operating system, Raspberry Pi or not.
Note: FTP is not a secure protocol, I would recommend using SFTP for production environments.
Login to SSH with
rootor a user which has sudo permissions. The default Raspberry Pipiuser should be okay.Update packages:
sudo apt-get updateCreate a new user, used only for FTP connections:
sudo adduser ftp-userEnter a password of your choice.
Create a folder in
/root. This is where the USB HDD will be permanently mounted.sudo mkdir /usb-hdd-storageMount the USB HDD to this folder, this assumes your USB HDD is formatted as NTFS. Firstly check to see the partitions available on the USB HDD drive:
sudo blkidThis should output the USB HDD's label, keep a note of this.
Check the boot name of the USB HDD's partition:
sudo fdisk -lNow we know where our drive is, we need to mount it to the
/usb-hdd-storagefolder we created previously:sudo mount /dev/sdaX /usb-hdd-storageYou may need to replace
Xwith your drive ID. This can be found from the 'blkid' command.You'll also have to set permissions to ensure the drive can be accessed properly:
sudo chmod 775 /usb-hdd-storageTo make the USB HDD mount permanently, edit the 'fstab' file:
sudo nano /etc/fstabAdd this line to the bottom of the file:
/dev/sdaX /usb-hdd-storage ntfs defaults 0 0As before, replace
Xwith your drive ID.Note: If you need to unmount the drive, run:
sudo umount /usb-hdd-storageCreate a folder in the 'ftp-user' home directory, this will be used in the next step to 'bind' to the folder we created in
/root/usb-hdd-storage:sudo mkdir /home/ftp-user/usb-hdd-storagePerform a bind to where the USB HDD is mounted. Edit the 'fstab' file so this bind is permanent:
sudo nano /etc/fstabAdd this line to the bottom of the file, it should be below the line which was added in the previous step:
/usb-hdd-storage /home/ftp-user/usb-hdd-storage none bind 0 0Now change the ownership of this folder to the 'ftp-user' user:
sudo chown ftp-user:ftp-user /home/ftp-user/usb-hdd-storageInstall proFTPd:
sudo apt install proftpdChoose to run proFTPd as
standalone.Now edit the proFTPd configuration file:
sudo nano /etc/proftpd/proftpd.confChange the
TimeoutIdlevalue to60. This is 60 seconds.And uncomment
DefaultRootso users are 'jailed' to their home directories, they will still be able to access files on the USB HDD because of the 'binded' folder we created.Reload the proFTPd service to pick-up the changes made in the configuration file:
sudo service proftpd reloadYou can now reboot the operating system and test the connection in a FTP program, such as FileZilla.
sudo shutdown -r nowOr to shutdown, run:
sudo shutdown -h now