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

Does anyone know of a way to do the following on Linux. I can't seem to find a way to run a script after the user is authenticated, but before the session starts...

  • User types username and password into GDM, LightDM, TTY, etc.
  • Rsync pulls their user's profile from a central server
  • User's session starts and they complete the days work normally
  • User logs out
  • Rsync updates user's profile on server

I can easily script everything listed above, I just don't know where to put the scripts to do this...


"Why not use NFS/CIFS/other-nas-protocol?"

High latency network, and spotty connection at times...

share|improve this question
up vote 4 down vote accepted

pam-script looks like a solution. A quote from the man page:

pam-script allows you to execute scripts during authorization, passwd changes, and on session opening or closing.

Such scripts can perform necessary tasks or influence the outcome of the PAM stack. For example, if the following entry was included in pam.conf

  sshd auth required pam_script

then if the script, pam_script_auth, exits with a non-zero value this would cause the user to be denied SSH access to the machine.

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.