3

I'd want to add a new feature to my Red Hat 5 so when any user opens a ssh remote session a broadcast message gets delivered to a defined user/all users. How to do it?

1 Answers1

1

You can hook the login system with pam (Pluggable Authentication Modules). There is a wonderful pam module for this named pam_script. It enables to run any script in any stages of the authatentication. It will yet be called with the privileges of the sshd, so it will be impossible for the user to manipulate this feature.

You can find pam_script on https://github.com/jeroennijhof/pam_script .

You should define a script for the session_open stage of the sshd. This script could then sending mails, or calling the "wall" command, as you wish.


There is a much simpler solution, although I didn't said it perfect. Simply type

echo 'I am logged in'|wall

into /etc/profile .

peterh
  • 2,782