FTP SERVER

David Tavares
2 min readAug 24, 2021

RPi

Disable auto login

  • Go to the main menu.
  • Open the Raspberry Pi Configuration tool, under Preferences.
  • In the first tab, click “Disabled” beside “Auto Login”:

Enable root

We need another user with privileges to change the default username, and the most natural way to do this is to use root.
You first need to enable it by setting a password :

You need to open a session with pi.
At this step you can use SSH, a terminal on Desktop or just open a session on the Lite version.

Type the command:

  • sudo passwd

This will set a password for root, allowing us to log in with it.

Create a new user

Most of the time, the method I use on a fresh installation is this simple one:

Log in with the “pi” user on first boot (automatic).

Configure the basic options with it.

As soon as you are ready, create a new user in command line.

$ sudo adduser <newuser>

Add the sudo privileges to it.

# usermod -aG sudo <newuser>

Reboot.

Login with the new username.

Delete the pi username.

#deluser -r pi

https://raspberrytips.com/change-raspberry-pi-username/

Create FTP folders

#mkdir -p /navigatordatalogger

#mkdir -p /navigatordatalogger/ftpserver

sudo chown nobody:nogroup -R /navigatordatalogger
sudo chmod 777 -R /navigatordatalogger

SETUP FTP SERVER

We’ll start by updating our package list and installing the vsftpd daemon:

sudo apt-get update

sudo apt-get install vsftpd

When the installation is complete, we’ll copy the configuration file so we can start with a blank configuration, saving the original as a backup.

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig

First, let’s check the firewall status to see if it’s enabled and if so, to see what’s currently permitted so that when it comes time to test the configuration, you won’t run into firewall rules blocking you.

sudo ufw status

sudo ufw allow ftp-data

sudo ufw allow ftp

sudo ufw status

sudo nano /etc/vsftpd.conf

listen=NO

listen_ipv6=YES

anonymous_enable=NO

local_enable=YES

write_enable=YES

dirmessage_enable=YES

use_localtime=YES

xferlog_enable=YES

connect_from_port_20=YES

chroot_local_user=YES
allow_writeable_chroot=YES
local_root=/navigatordatalogger/ftp

secure_chroot_dir=/var/run/vsftpd/empty

pam_service_name=vsftpd

rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

pasv_min_port=40000
pasv_max_port=50000

sudo systemctl restart vsftpd

sudo systemctl status vsftpd

https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-for-anonymous-downloads-on-ubuntu-16-04

RUN PROGRAM ON RPi STARTUP

https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/

sudo nano /etc/rc.local

sudo python3 /navigatordatalogger/python/directory_watchdog.py & > /navigatordatalogger/logs/python_directory_watchdog_boot_log.txt 2>&1

sudo python3 /navigatordatalogger/python/datalogger_system_check.py & > /navigatordatalogger/logs/python_datalogger_system_check_boot_log.txt 2>&1

sudo reboot

— — — — → Install Python with non root previleges ← — — — — —
https://raspberrytips.com/install-latest-python-raspberry-pi/

--

--