How to Integrate a 2 Door DX Access Control Board and Our DVRs with Alarm Inputs
May 28, 2015
TechPro Security Products – 2015 – Our Biggest Year Ever!
June 1, 2015

Low Powered FTP Server with Raspberry Pi Goodness.

SCK RASPPI

There comes a time where you need to have an FTP server and do not want to spend money on a machine that will be there 24/7. Here is the solution. All you will need are the following items and some optional ones to make it awesome ;).

(1) Raspberry Pi B /B+ or 2.

(1) 2amp 12VDC Adapter [USB] for power.

(1) USB to Sata Drive, for storage

Installing the OS Image onto the SD Card
logo_raspbian-france_250px

Lets start by installing the image of Raspbian onto an SD card, I will be using a 32GB Class 10 SD card. These are great as they are fast and reliable.

Lets find the letter that the computer assigned the SD card and lets open the SD formatter tool, format the correct drive and move onto opening up the Win32 Imager tool.

select the correct Image and hit “Write” this will take some time so go make a cup of coffee…..

cup-of-joe-funny-memes

Once we have done this we will install the SD Card onto the raspberry pi ensuring that it is well seated. Lets turn it on by connecting the USB Connection.

Go ahead and expand the system files, select the “PI” Password and your local time. I also changed my local host name as I will be using this raspberry pi for other purposes and I already have another in my home network. After this is done the raspberry pi will boot up asking for a username and password. I elected to leave it in “command line mode” I do not need it to be running a desktop style background for this and it helps with performance. If you are skilled, you can also overclock this baby and just add heat sinks and fans to cool down the raspberry pi.

Installing updates

Lets go ahead and download any updates and install them, we will do this by imputing the following code onto the terminal

#sudo apt-get update

#sudo apt-get upgrade -y

This will take some time, after this is done we will install “VSFTPD

#sudo apt-get install vsftpd -y

After this is done we need to use nano to edit a configuration file we do this by imputing the following command.

#sudo nano /etc/vsftpd.conf

We will need to edit some lines and writout the file and exit.

Here are the lines that need to be changed.

anonymous_enable=YES  
to 
anonymous_enable=NO

We need to uncomment a few things to enable them. Uncomment by removing [#] 

#local_enable=YES 
to 
local_enable=YES

If you want to enable FTP uploading for the user in their home directory, uncomment the write_enable line by changing

#write_enable=YES

to

write_enable=YES

You have the ability to have users locked onto their home directory

chroot_local_user=YES

After this click on CRTL + O to write out the file and exit by clicking on CTRL X
We next need to enable FTP Root user this may be already set but its good to check you can also add pi to the list or any other users.

We will use again the awesome command nano.
#sudo nano /etc/ftpusers

Uncomment the
#root

After this click on CRTL + O to write out the file and exit by clicking on CTRL X
You also want to change the Root Password to set the root password use the following command where root can be any other user.

#sudo passwd root

This will ask you for a new password and confirm it by imputing once again.

We will then restart the service by entering the following command.

#sudo service vsftpd restart

This will allow you to log into your system via FTP but there is more you will need to add a USB External Drive so as to not use the internal storage on your SD card.

We will do this by shutting down your raspberry pi and plugin your USB External drive onto the raspberry pi USB ports.

We will use the following command as we do not want to just unplug the raspberry pi as a method to shutting it down.

#sudo shutdown -h now

Setting up an External Drive to handle the files

We will need to ssh into the raspberry pi once more and input the following command to create some directories.

#sudo mkdir /media/shares

#sudo mkdir /media/shares/data

Then we input:

#sudo blkid

This will give you the following output, in mine it is

Capture

our drive is /dev/sda1 with a UUID=”3CD8-1613″

Once you know this information you will need to input this command

#sudo nano /etc/fstab

Add this line

#UUID="3CD8-1613/media/shares/data auto uid=pi,gid=pi,noatime 0 0

hit CTRL + O to write out the file and exit by CTRL + X

Then we mount the drive by using this command:

#sudo mount -a

after this you should be able to access the folder/files

#cd /media/shares/data

and display the file contents using

#ls -lah

If you external Drive has a format of NTFS we will need to install ntfs-3g

#sudo apt-get install ntfs-3g

then mount your drives

#sudo mount -a

Once you have done this we will move to our Recorder.

Setting up our NVR/DVR to send information to our Low Powered FTP Server

We will need to access the recorder’s IP address – in my case it is 192.168.1.130

I have the default passwords set for this demonstration.

I navigate to the “Setup” tab then select the “Network” tab and finally click on “FTP”

A new window will appear and we will be imputing the Raspberry Pi FTP servers IP address.

Host IP = 192.168.1.134

Port = 21 (default) can be changed in the raspberry pi.

User Name = root (lower case)

Password = your password

remote directory is = /media/shares/data

File Length = I set this to 20 Minutes

Image Upload Interval = 2 (Default)

Channel = All ( Or any of your choosing)

and select the periods and recording based on motion, alarms or Regular. Click on Save and you are done.

Once last thing is to set the Raspberry pi to that specific IP address, meaning Static IP Address.

Setting the Raspberry Pi Static IP Address

Setting up the RPI to Static IP is simple.

Log in as usual with SSH using Putty

We will back up some files just in case.

#sudo cp /etc/network/interfaces /etc/network/interfaces.sav

Then we will open the configuration file

#sudo nano /etc/network/interfaces

uncomment the line “iface eth0 inet dhcp”

It should be

#iface eth0 inet dhcp

then we will add
 # The loopback interface
 auto lo
 iface lo inet loopback
 auto eth0
 iface eth0 inet static
 #your static IP
 address 192.168.1.118  
 #your gateway IP
 gateway 192.168.1.1
 netmask 255.255.255.0
 #your network address "family"
 network 192.168.1.0
 broadcast 192.168.1.255

The comments will let you know what items to change in my case I only had to change the IP address to 192.168.1.134.

Voila!
You are done. Reboot the RPI and you should be set.

Jose Malave
Jose Malave
IT Director. for Techpro Security Products - Security Camera King

Leave a Reply

Your email address will not be published. Required fields are marked *