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

Comments

Joe G Rodriguez
  • October 24th, 2018

10/24/2018

This is the First Raspberry Pi 3 FTP Server that loaded with no Errors. I really Appreciate the USB Hard Drive Load addition.
I just hope I can Figure out how to Send Data from a Security Camera to this Server???

Thanks

Joe

Joe G Rodriguez
  • October 24th, 2018

I did everything as stated on this page. When I logged in FileZilla I Typed in My IP 192.168.1.146 (I did not anything in front of the IP) FileZilla Put in (sftp://192.168.1.146) User Name: Pi and my: Password. I left Port: Blank.
I get a listing but I can’t find the HDD???
All the Folders have ? marks in the Folders.
Can you help?

Ryan
  • October 25th, 2018

Hi Joe, Did you change directory to the HDD mount point? In my case, the mountpoint was stored as ‘usb-hdd-storage’ within the ‘ftp-user’ home directory. Your setup might be different, but if you followed the tutorial exactly, you should be able to transfer files to the HDD in FileZilla by changing directory to this location: /home/ftp-user/usb-hdd-storage

Joe Rodriguez
  • October 29th, 2018

Ryan thanks for the reply. I’m going to start all over again with a new Raspbian System. I just had Surgery so I lost a few Days and I’m not supposed to sit at the Computer very Long. But, I just have to try again. I will follow everything exactly as you have it. You have my email. I wish I could get yours so I can get this right.
For your information I’m trying to set the Raspberry Pi 3 with 1tb Western Digital Ultra up as an FTP Server for Security Camera.
Thanks

Joe
San Antonio, TX

Joe G Rodriguez
  • October 30th, 2018

Ryan
I just reloaded everything as per your instructions. I’m using Filezilla on a Windows 10 64 Desktop. Everything looked like loaded right except for the New Version of ProFTPD does not ask for Standalone.
Now how do I login to Filezilla My address if 192.168.1.146 do I need anything infront of the IP? What do login with FTP-user or Pi or what? I guess my password is the one I used?
Thanks

Joe

Joe G Rodriguez
  • October 30th, 2018

Ryan – I logged in to Filezilla with my IP and My Password.
Status: Connecting to 192.168.1.146:21…
Status: Connection established, waiting for welcome message…
Status: Insecure server, it does not support FTP over TLS.
Status: Logged in
Status: Retrieving directory listing…
Status: Directory listing of “/” successful
Status: Retrieving directory listing of “/usb-hdd-storage”…
Command: CWD /usb-hdd-storage
Response: 550 /usb-hdd-storage: No such file or directory
Error: Failed to retrieve directory listing
Status: Retrieving directory listing of “/usb-hdd-storage”…
Command: CWD /usb-hdd-storage
Response: 550 /usb-hdd-storage: No such file or directory
Error: Failed to retrieve directory listing
Status: Connection closed by server
Can you email me so I can fix this. You have my Email. I have screen captures of everything I did.
Thanks

Joe

Ryan
  • October 30th, 2018

Hi Joe,

Looks like it is logging in properly, but seems the issue is with the USB HDD mountpoint. Have you created the ‘usb-hdd-storage’ in the root? If so, re-try the steps to mount your hard drive to this folder. If it’s still not working, then unfortunately i’m not sure. I tested this myself when I wrote the post on Raspberry Pi 3 and it worked perfectly.

Joe G Rodriguez
  • October 31st, 2018

Ryan
I don’t know if this shows where the HD is mounted but let me know what to type to find out?
pi@jgrpi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 4.5G 24G 17% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 13M 452M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 41M 22M 19M 54% /boot
/dev/sda1 932G 205M 932G 1% /usb-hdd-storage
tmpfs 93M 0 93M 0% /run/user/1000
Thanks
Joe

Ryan
  • November 3rd, 2018

Looks like your hard drive is mounted, I can see 900gb. Have you tried either the pi or FTP user for logins?

Post a Comment