Changes

From Amahi Wiki
Jump to: navigation, search
320 bytes added ,  00:46, 3 November 2014
no edit summary
'''NOTE:''' You must have configured your HDA to send emails. One way to do so is by following the [[Outgoing_mail_via_gmail|Outgoing mail via Gmail]] guidance.
== Method 1 ==* [[Open_Terminal|As root user]] create ''/usr/bin/ssh_email_alert.sh'' with the following text:
<pre>#!/bin/bash
echo "SSH Login:" >> $tmptxt
echo "`who -m`" >> $tmptxt
 
echo "" >> $tmptxt
echo "Current sudo:" >> $tmptxt
echo "`whoami`" >> $tmptxt
 
echo "" >> $tmptxt
* Set execute permissions:
chmod 755 /usr/bin/ssh_email_alert.sh
* Edit ''/etc/profile'' and add this to the bottom of the file:
ssh_email_alert.sh
You should not get an email anytime a user logs into your HDA via Reference: [[Key-Based http://linux.alanstudio.hk/ssh_emailalert.htm Email Alert for SSH Logins|Secure Shell (SSH)login]].
== Method 2 ==
* [[Open_Terminal|As root user]] edit ''/etc/profile'' and add this to the bottom of the file:
<pre>if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): SSH login to ${USER}@$(hostname -f)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "SSH Login" name@domain.com
fi</pre>
Reference: You should not get an email anytime a user logs into your HDA via [http://linux.alanstudio.hk/ssh_emailalert.htm Email Alert for [Key-Based SSH Logins|Secure Shell (SSH login)]].
12,424

edits