Email alerts whenever someone logs into server via SSH any user?

Hi all,

Thanks in Advance!!

I dont know how to start to write script for this process, my requirement is if any user logs into server automatically Admin get mail alert. how is this possible? any one guide me to complete this process.

Like this?

while true; 
do   
  who > /tmp/user.$$;   
  val=$(diff /tmp/user.log /tmp/user.$$);   
  test ! -z "$val" && echo -e "$val" | mail you@you.com
  mv /tmp/user.$$ /tmp/user.log;   
  sleep 10
done

--ahamed

---------- Post updated at 05:00 AM ---------- Previous update was at 04:58 AM ----------

You can differentiate the user logged in/logged out using the > or < from the diff command output. I am not sure if there is a utility already exists for this.

--ahamed