Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
this script wolld be executed just after the validation of login / password.
If your distro uses PAM (got dir and files in /etc/pam.d) you prolly can use something like the pam_script module.
If they are using the BASH shell, add the following line to their /home/user/.bash_profile file:
/path/to/executable/script.php
or
sh /path/to/script
Both shell scripts and php scripts can be made executable - and PHP could be easier to send mail from. If you are planning to do it for all users, you will have to edit each users .bash_profile aswell as the/etc/skel/.bash_profile
/etc/skel is a directory that is used to create all new user dirs from - if its in the /etc/skel directory then it will be in the new users directory. This applies to the contents of files in /etc/skell
do you think i can do the same with pam ?
Should go something like this.
1. Install pam_script.so if you haven't got it in /lib/security/
2. Add this line in /etc/pam.d/sshd under the other "session" statements:
OK, using mailx package is nice, but you really want to forge either a no-return@ address or a general address like "info@". To do this I pipe the message (Subject: and body) tru sendmail using -F and -f. Side effect from this is you will need a privileged (non-root account) user to run the script as (runas=) , else you'll have an X-Auth warning header saying the luser faked the From: address. However I set the permissions on the runnable script and whatever user I use, it ain't working. Besides that logging out of a ssh session seems to halt at "logout", and the /etc/login.defs fix (CLOSE_SESSION) doesn't work as advertised either.
Long story short, pam_script doesn't work as I want it to work, so forget it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.