3

I would like to run a script after a linux user logs in to do some additional security checks. The user should first login normally using their password, but then be checked with my script, and then get full access to the system. Is this possible?

2
  • 2
    Are you sure you really want to have it happen post-login? With PAM you can do a lot of checking.
    – Zoredache
    Sep 11, 2014 at 19:42
  • No I'd rather add an extra step to the authentification. Is that possible with PAM?
    – RealWorld
    Sep 13, 2014 at 0:09

2 Answers 2

4

Assuming all your users are using bash, then the file /etc/profile is executed on login. On some distros there is an /etc/profile.d. You could drop your login script into this directory.

0

If you're trying to do this for EVERY user on the system that may log into a bash shell (basically root, and any other "normal" user), then you'll want to add the command into /etc/profile or add the script into /etc/profile.d/ depending on your system.

If, however, you're trying to do this for a specific user, the place to add it would be into that user's ~/.bash_profile or ~/.profile.

See this page for more information on the files, as well as /etc/bashrc/~/.bashrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .