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.

  1. Login to SSH with root or a user which has sudo permissions. The default Raspberry Pi pi user should be okay.

  2. Update packages:

    sudo apt-get update
    
  3. Create a new user, used only for FTP connections:

    sudo adduser ftp-user
    

    Enter a password of your choice.

  4. Create a folder in /root. This is where the USB HDD will be permanently mounted.

    sudo mkdir /usb-hdd-storage
    
  5. 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:

    sudo blkid
    

    This should output the USB HDD's label, keep a note of this.

  6. Check the boot name of the USB HDD's partition:

    sudo fdisk -l
    
  7. Now we know where our drive is, we need to mount it to the /usb-hdd-storage folder we created previously:

    sudo mount /dev/sdaX /usb-hdd-storage
    

    You may need to replace X with 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
    
  8. 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 X with your drive ID.

    Note: If you need to unmount the drive, run:

    sudo umount /usb-hdd-storage
    
  9. 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 /root/usb-hdd-storage:

    sudo mkdir /home/ftp-user/usb-hdd-storage
    
  10. 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
    
  11. Now change the ownership of this folder to the 'ftp-user' user:

    sudo chown ftp-user:ftp-user /home/ftp-user/usb-hdd-storage
    
  12. Install proFTPd:

    sudo apt install proftpd
    

    Choose to run proFTPd as standalone.

  13. Now edit the proFTPd configuration file:

    sudo nano /etc/proftpd/proftpd.conf
    

    Change the TimeoutIdle value to 60. This is 60 seconds.

    And uncomment DefaultRoot so 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.

  14. Reload the proFTPd service to pick-up the changes made in the configuration file:

    sudo service proftpd reload
    
  15. 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
    

Discuss on X (Twitter)