Pure-FTPd on a Raspberry Pi

We want to use the FTP (File Transfer Protocol) to transfer snapshots between our INSTAR IP camera an our Raspberry Pi. Follow the steps below to set up an FTP server.

Installation

  1. Use your SSH terminal (Windows user can use the free Terminal from Mobaterm) to connect to your Pi (default login: user = openhabian and password = openhabian for an openHABian Installation).
  2. Install Pure-FTPd using the following command line in Terminal: sudo apt-get install pure-ftpd.

Basic Configurations

  1. We need to create a new user group named ftpgroup and a new user named ftpuser for FTP users, and make sure this "user" has no login privilege and no home directory:
sudo groupadd ftpgroup
sudo useradd ftpuser -g ftpgroup -s /sbin/nologin -d /dev/null

FTP Home Directory, Virtual User and User Group

  1. We already created a public directory inside the /.node-red/static/ folder in our openhabian home directory. Make a new directory named ftp with a subfolder for our first camera (in my case it will be officecam):
sudo mkdir /home/openhabian/.node-red/static/ftp/officecam/
  1. You will be asked for your password, which is openhabian by default - but you might have changed that in an earlier step.
  2. Make sure the directory is accessible for ftpuser, so our camera will be able to read and write files from/to it:
sudo chown -R ftpuser:ftpgroup /home/openhabian/.node-red/static/ftp/officecam/
  1. Create a virtual user named upload, mapping the virtual user to ftpuser and ftpgroup, setting home directory /home/openhabian/.node-red/static/ftp/, and record password of the user in database. Notice that we set the path to /home/openhabian/.node-red/static/ftp/ and NOT to /home/openhabian/.node-red/static/ftp/officecam - this way we can use the same FTP user for all our cameras and just have to assign different upload directories in the FTP Configuration of our cameras - ./officam in case of our first camera. In your case it might make sense to use a different FTP user with a different home directory for each camera? You can make that decision here:
sudo pure-pw useradd upload -u ftpuser -g ftpgroup -d /home/openhabian/.node-red/static/ftp/ -m
  1. Type in a password for this virtual user once you are prompted for it.
  2. And next, set up a virtual user database by typing:
sudo pure-pw mkdb
  1. Last but not least, define an authentication method by making a link of file /etc/pure-ftpd/conf/PureDB:
sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb
  1. Restart the program:
sudo service pure-ftpd restart
  1. You can test the FTP Upload with your INSTAR camera using the FTP Test function:

INSTAR Camera FTP Setup

Go back to your Terminal and go to the upload directory and list all files:

cd /home/openhabian/.node-red/static/ftp/officecam
ll

INSTAR Camera FTP Setup

Your test upload should be listed below - a JPG image file with a name that starts with a T and a timestamp:

INSTAR Camera FTP Setup