Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to run a bash script everytime someone opens an FTP session on Linux. Ideally, the solution should be compatible with any FTP server. Perhaps a way to detect when credentials are accepted at a certain port. Any ideas?

share|improve this question

1 Answer 1

You can write a script that parses the log file of say ftp daemons such as vsftpd and proftpd and do something once it finds a line that matches what you want. However it would be different for each daemon as each has their own log style. On top of which, there will be delay as you will probably have to poll the file to see if its changed.

A perhaps more portable solution and better response time would be to make a PAM module(WAY MORE WORK THOUGH) A lot of daemons have PAM support built in. so when someone logs into ssh for instance it will query PAM and the PAM config will pick for the login whether LDAP or UNIX file. then it has like password modules like cracklib to check if it works.

it short you can append this line to the pam config of the particular service once you make a pam module. session required /lib/security/pam_yourmodule.so

http://www.linux.com/archive/feature/113567 for a quick primer on PAM.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.