Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
cancel
Showing results for 
Search instead for 
Did you mean: 

vsftpd and email notication

K.C. Chan
Trusted Contributor

vsftpd and email notication

All I am wondering if some one have done this before, I have set up an ftp server and I want to be able to get notify via email if someone upload a new file to the ftp server. Suggestions anone? Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
10 REPLIES
Olivier Drouin
Trusted Contributor

Re: vsftpd and email notication

looks like a task for cron.

and to send mail....

echo "Found new file" | mail -s "the subject" your@email.address
K.C. Chan
Trusted Contributor

Re: vsftpd and email notication

Ok, maybe I have not phrased the question properly. I need to know how to detect when a new file is uploaded. I need idea on how to script it out.

What I am thinking is taking a listing of the dir and saved it to a file, then check it again sometime later and take a the listing of the dir and save it. Then do a checksum on the two files, if they differ (assuming they differ because new files was uploaded) than send an email out. What do you think?
Reputation of a thousand years can be determined by the conduct of an hour
Paul Cross_1
Respected Contributor

Re: vsftpd and email notication

I haven't done this, so my thoughts are untested and high-level but I'm thinking that if you are using wu-ftpd, you could set the log transfers directive to log incoming files, and script the diffs. Instead of running it from cron, you could write a simple wrapper for ftpd, something like:

#!/bin/sh
/usr/sbin/in.ftpd
/usr/bin/checkftplogdiffs

When inetd or xinetd kills ftpd, it would trigger a check on the logs which would in turn email you if there has been a new file uploaded...

Steven E. Protter
Exalted Contributor

Re: vsftpd and email notication

I turn on enhanced logging in xinetd.conf and then have a job that periodically scans the /var/log/messages files for all connections. They are so few usually, accept the time someone tried to use 5000 ftp logon attempts in a vain attempt to guess a password for common user names.

If you break out the ftp logging to its own file, you can use a grep | mail "subject" emailaddy script to let you know whats going on.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Alexander Chuzhoy
Honored Contributor

Re: vsftpd and email notication

Maybe using tripwire will assist you.This way you'll know when something's changed on monitored directories...


K.C. Chan
Trusted Contributor

Re: vsftpd and email notication

All,
these are nice solution, but I am not doing this for security reasons. This ftp server, have serveral ftp accounts and someone within our company is responsible for downloading file when there are new files on the ftp server. The files are uploaded by third party member, but they do not notify when new files are uploaded. So I need something that will notify someone in our company that there are new files being uploaded, so we can go get them.
Reputation of a thousand years can be determined by the conduct of an hour
Alexander Chuzhoy
Honored Contributor

Re: vsftpd and email notication

Still not perfect but closer to your goal-


You can edit /etc/hosts.allow file and to add a line like this....


vsftpd : IP (of the client that usually uploads the file) :spawn echo "There's some action from %c" |mail -s "FTP action" your_email_address


Hope it helps.
K.C. Chan
Trusted Contributor

Re: vsftpd and email notication

hosts.allow looks promising, but I am getting this error and trying to get past it:
vsftpd: warning: can't get client address: Bad file descriptor
any idea? Thanks.
Reputation of a thousand years can be determined by the conduct of an hour
Alexander Chuzhoy
Honored Contributor

Re: vsftpd and email notication

Can this host send e-mails ?
try only to send e-mail with this command?

echo "hi" |mail -s "Test" e-mail_address.
K.C. Chan
Trusted Contributor

Re: vsftpd and email notication

I'm getting closer, but all I get is the ip the ftp session is comming in as, I need to know which user is loggin into the ftp server so I can email apropiate people within my company. When I added "%u", user is showing up is unknown, any idea on how to get this information? Thanks.
Reputation of a thousand years can be determined by the conduct of an hour