Re: Running a script on login
From: Nicolas Alejandro Salvo (nsalvo_at_pictage.com.ar)
Date: Sun, 11 Sep 2005 15:00:03 -0300 To: email@example.com
You can use something like this in /etc/hosts.allow
sshd : xxx.xxx.xxx/8 : spawn (echo -e "External ssh connection from %h
" | mail -s "SSH connection from Internet" firstname.lastname@example.org) : ALLOW
Chris Jensen wrote:
>I'm trying to figure out how to run a script upon a successful login
>(of any user) via openssh.
>The ssh server is being setup for very limited remote access, so we'd
>like to monitor logins by having an email sent to the administrator
>whenever a user is successfully logged in.
>We only want the script to trigger for openssh logins (local logins
>we're not interested in), but I can't figure out how to set this up
>other than in the .bash_profile
>The other thing I considered was having a cron job watch the
>authentication logs, but I'd prefer something that runs only when
>necissary than having to constantly poll the logs.
>I've googled and come up with nothing, and read through all the config
>options and can't find anything. I also thought of using a PAM module
>to do this, but can't find anything appropriate.