Below is my complete guide for setting up a Reolink camera to backup to FTP hosted on Tardigrade. The setup was conducted on a fresh Ubuntu 20.04 LTS Server installation. I generally recommend using tmux or byobu to allow one to open multiple shell windows. This guide uses the following components:
- Tardigrade Uplink S3 Gateway
- AWS CLI tool
- s3fs
- vsFTPd
Prerequisites
Create and fund a Tardigrade.io account. Create a project and an API Key as shown on the Tardigrade documentation site.
Uplink S3 Gateway and AWS CLI Tool
Install Uplink S3 Gateway.
$ curl -L https://github.com/storj/gateway/releases/latest/download/gateway_linux_amd64.zip -O && unzip gateway_linux_amd64.zip
$ chmod 755 gateway
$ sudo mv gateway /usr/local/bin/gateway
Also install the aws
CLI tool.
$ sudo apt install awscli
Complete the S3 Gateway setup with the satellite, API key, and encryption password.
$ gateway setup
Select your satellite:
[1] us-central-1.tardigrade.io
[2] europe-west-1.tardigrade.io
[3] asia-east-1.tardigrade.io
Enter number or satellite address as "<nodeid>@<address>:<port>" [1]: 1
Enter your API key: <api key>
Enter your encryption passphrase:
Enter your encryption passphrase again:
With your permission, Tardigrade can automatically collect anonymized analytics information from your S3 Gateway and send it to Storj Labs (makers of Tardigrade) to help improve the quality and per
formance of our products.
Do you agree to submit such information to Storj Labs (y/N): y
Your S3 Gateway is configured and ready to use!
Some things to try next:
* See https://documentation.tardigrade.io/api-reference/s3-gateway for some example commands
Run the gateway
$ gateway run
2020-05-06T02:00:50.481Z INFO Configuration loaded {"Location": "/home/ubuntu/.local/share/storj/gateway/config.yaml"}
2020-05-06T02:00:50.489Z INFO Starting Storj S3-compatible gateway!
2020-05-06T02:00:50.490Z INFO Endpoint: 127.0.0.1:7777
2020-05-06T02:00:50.490Z INFO Access key: <access key>
2020-05-06T02:00:50.491Z INFO Secret key: <secret key>
Configure the aws
CLI tool
$ aws configure
AWS Access Key ID [None]: <access key>
AWS Secret Access Key [None]: <secret key>
Default region name [None]:
Default output format [None]:
Create a new bucket in the Tardigrade project for the FTP data.
$ aws s3 --endpoint=http://localhost:7777/ mb s3://ftp
make_bucket: ftp
vsFTPd
Install vsFTPd.
$ sudo apt install vsftpd
Create a vsftpd.conf
file, replacing <local IP address>
with your local IP address.
$ sudo su -
$ mv /etc/vsftpd.conf /etc/vsftpd.conf.bak
$ cat > /etc/vsftpd.conf << EOF
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
listen=YES
pam_service_name=vsftpd
tcp_wrappers=YES
user_sub_token=\$USER
local_root=/srv/ftp
pasv_min_port=40000
pasv_max_port=50000
pasv_address=<local IP address>
userlist_file=/etc/vsftpd.userlist
userlist_enable=YES
userlist_deny=NO
EOF
$ exit
Add the local FTP user to the vsftpd.userlist
file and start the vsftpd
service.
$ echo "ubuntu" | sudo tee -a /etc/vsftpd.userlist
ubuntu
$ sudo systemctl enable vsftpd
$ sudo systemctl start vsftpd
Create a local folder for the ubuntu
user in the FTP root.
$ sudo mkdir /srv/ftp/ubuntu
$ sudo chown ubuntu:ubuntu /srv/ftp/ubuntu
s3fs
s3fs is used to create a local mount point for the vsFTPd user folder hosted on Tardigrade and exposed via the Uplink S3 Gateway.
Install s3fs.
$ sudo apt install s3fs
Create a credentials file for s3fs with the S3 Access key and Secret key as defined in the Tardigrade gateway tool.
$ echo <access key>:<secret key> > ${HOME}/.passwd-s3fs
$ chmod 600 ${HOME}/.passwd-s3fs
Mount the S3 bucket to the local /srv/ftp/ubuntu
directory created during the vsFTPd installation.
$ s3fs ftp /srv/ftp/ubuntu -o passwd_file=${HOME}/.passwd-s3fs \
-o url=http://localhost:7777/ -o use_path_request_style
Reolink POE Camera FTP Setup
I have a few Reolink POE RLC-420-5MP turret security cameras that I generally access via RTSP but they also allow for FTP connectivity. In the Web UI of the camera, I’ve set the FTP server settings and set the mode to passive (i.e. PASV). For this test, I’m taking a still image every 30 seconds for 24/7 upload.
With these settings, I can confirm that the files are showing on the local mountpoint as well as the S3 bucket.
$ tree -r /srv/ftp/ubuntu
.
└── 2020
└── 05
└── 05
├── Front_Door_01_20200505221130.jpg
├── Front_Door_01_20200505221100.jpg
├── Front_Door_01_20200505221041.jpg
└── Front_Door_01_20200505221038.jpg
3 directories, 4 files
$ aws s3 --endpoint=http://localhost:7777/ ls s3://ftp/2020/05/05/
2020-05-06 04:11:34 333027 Front_Door_01_20200505221130.jpg
2020-05-06 04:10:42 262144 Front_Door_01_20200505221038.jpg
2020-05-06 04:10:37 0
2020-05-06 04:11:04 333836 Front_Door_01_20200505221100.jpg
2020-05-06 04:10:45 330283 Front_Door_01_20200505221041.jpg
Hopefully this helps shed some light on how one could leverage FTP to connect CCTV to Tardigrade. I’ll keep this running for a while to test out the stability.
References
Along with links scattered throughout this post, I found the below article instrumental in getting the above setup working for me.