Page 1 of 1
sftp/openssh support
Posted: Wed Oct 15, 2008 2:28 am
by majost
It would be really nice if zoneminder supported sftp. Aside from encrypting the transfer of tarballs to the remote host, it also allows one to use public key encryption and passwordless logins.
I can't speak for anyone else... but sftp/openssh is far less work for me than maintaining an ftp server.
SFTP Script
Posted: Wed Oct 15, 2008 6:40 am
by cordel
You can already do this with an external script which is far more functional:
Code: Select all
#!/bin/sh
#----------------------------------------------------------------------------
# USAGE: To be executed by ZM-Filter
#
# DESCRIPTION:
# OPTIONS: None
# REQUIREMENTS: tar, bzip
#
# AUTHOR: Corey DeLasaux
# VERSION: 1.0
# CREATED: 10/14/2008 20:18:00 PDT
# MODIFIED:
# Notes:
# Licence: RPl 1.5
#=============================================================================
# Unless explicitly acquired and licensed from Licensor under another
# license, the contents of this file are subject to the Reciprocal Public
# License ("RPL") Version 1.5, or subsequent versions as allowed by the RPL,
# and You may not copy or use this file in either source code or executable
# form, except in compliance with the terms and conditions of the RPL.
#
# All software distributed under the RPL is provided strictly on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND
# LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
# LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific
# language governing rights and limitations under the RPL.
#=============================================================================
Server=192.168.0.25
User=public
Pass=qwerty
ZM_CONFIG=/etc/zm.conf
Monitor=$1
Event=$2
File=/tmp/ZM_Event_$Event.tar.bz2
if [ -f $ZM_CONFIG ]; then
. $ZM_CONFIG
else
echo "ERROR: $ZM_CONFIG not found."
exit 1
fi
GetEventPath="select Value from Config where Name='ZM_DIR_EVENTS'"
EVENT_PATH=`echo $GetEventPath |mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
tar -cjf $File $ZM_PATH_WEB/$EVENT_PATH/$Monitor/$Event
###############
### ssh or sftp or whatever you want added here:
### If you don't want to specify a password you need to generate a passwordless
### key with ssh-keygen and then copy the public key to the target host's ~/.ssh/authorized_keys file.
### As far as sftp creating a cert might be easier than using a password as the password would need
### to passed through a batchfile I belive and possibly the rest of the tranfer script (cd and put statements).
## Example:
#
# sftp -b /dev/stdin $User@$Server <<EOF
# $Pass
# cd /pub/uploads/events
# put $File
# bye
# EOF
##########
rm -f /tmp/ZM_Event_$Event.tar.bz2
exit 0
Posted: Sun Jan 18, 2009 10:00 pm
by majost
I finally got around to trying to implement this on my zm server. One thing which is unclear to me and I am having difficulties figuring out, how do I define a filter for the most recent event(s)?
The question itself seems fairly simple, but when I apply it to practice I get vastly different results. This is to say, I created a filter which has the parameter of the date/time < now -- and then limited it to the first 5 events. When I run this query, the Events shown in the web UI are always consistent. However, when I execute a script which just echos the values $1 and $2 to a log file I get completely unpredictable results, and none of the events which are shown as matching from the same filter in the web UI.
Am I missing something here?
Posted: Fri Jan 23, 2009 3:45 pm
by zoneminder
You could of course simplify the script somewhat if you mount your remote partition via sshfs and then just use regular file copies.