views:

279

answers:

4

Hi

I'm using vsftpd and I want to write a shell script that will detect a connection to my server and send me an email with information who and when has logged in. I don't know where to start. Can someone point me in the right direction.

Thanx

A: 

I'm not familiar with vsftpd, but you could have your shell script look at the output of netstat to see if you've got any connections on port 21 (the default ftp port).

Chris Simmons
that's a good start, thanx
6bytes
Although with this he wouldn't know who logged in as requested in the question :(
victor hugo
Good point - that'll teach me to skim the question.
Chris Simmons
+4  A: 

Read the log.

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/ref-guide/s1-ftp-vsftpd-conf.html

Enable the transfer log.

Read the file.

S.Lott
A: 

The most reliable way is using log analysis. If you use a tool like OSSEC (free and open source), it can run any scripts or generate email alerts when logins, logouts, failed logins, etc happens.

link: http://www.ossec.net

Sucuri
A: 

Same applies for "fail2ban", though the purpose of this thing is something else (you guessed it).

J.

TheBonsai