Quick and easy FTP server install on a Raspberry Pi
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 Pi
piuser should be okay.
sudo apt-get update
Create a new user, used only for FTP connections:
sudo adduser ftp-user
Enter a password of your choice.
Create a folder in
/root. This is where the USB HDD will be permanently mounted.
sudo mkdir /usb-hdd-storage
Mount 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:
This should output the USB HDD’s label, keep a note of this.
Check the boot name of the USB HDD’s partition:
sudo fdisk -l
Now 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-storage
You 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-storage
To make the USB HDD mount permanently, edit the ‘fstab’ file:
sudo nano /etc/fstab
Add this line to the bottom of the file:
/dev/sdaX /usb-hdd-storage ntfs defaults 0 0
As before, replace
Xwith your drive ID.
Note: If you need to unmount the drive, run:
sudo umount /usb-hdd-storage
Create a folder in the ‘ftp-user’ home directory, this will be used in the next step to ‘bind’ to the folder we created in
sudo mkdir /home/ftp-user/usb-hdd-storage
Perform a bind to where the USB HDD is mounted. Edit the ‘fstab’ file so this bind is permanent:
sudo nano /etc/fstab
Add 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 0
Now change the ownership of this folder to the ‘ftp-user’ user:
sudo chown ftp-user:ftp-user /home/ftp-user/usb-hdd-storage
sudo apt install proftpd
Choose to run proFTPd as
Now edit the proFTPd configuration file:
sudo nano /etc/proftpd/proftpd.conf
60. This is 60 seconds.
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 reload
You can now reboot the operating system and test the connection in a FTP program, such as FileZilla.
sudo shutdown -r now
Or to shutdown, run:
sudo shutdown -h now