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.
- 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).
- Install Pure-FTPd using the following command line in Terminal:
sudo apt-get install pure-ftpd.
- 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
- 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/
- You will be asked for your password, which is
openhabianby default - but you might have changed that in an earlier step.
- 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/
- 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 -
./officamin 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
- Type in a password for this virtual user once you are prompted for it.
- And next, set up a virtual user database by typing:
sudo pure-pw mkdb
- Last but not least, define an authentication method by making a link of file
sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb
- Restart the program:
sudo service pure-ftpd restart
- You can test the FTP Upload with your INSTAR camera using the FTP Test function:
Go back to your Terminal and go to the upload directory and list all files:
cd /home/openhabian/.node-red/static/ftp/officecam ll
Your test upload should be listed below - a JPG image file with a name that starts with a T and a timestamp: