Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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/ for a quick primer on PAM.

share|improve this answer

Your Answer


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.