Changes

From Amahi Wiki
Jump to: navigation, search
413 bytes added ,  00:47, 3 November 2014
no edit summary
This guide shows a simple way to know when someone logged in as root or normal user using [[Key-Based SSH Logins|Secure Shell (SSH)]]. It will send an email alert notification to the specified email address along with the IP address of last login.
'''NOTEPREREQUISITE:''' 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 Reference: [http://linux.alanstudio.hk/ssh_emailalert.htm Email Alert for SSH login] == Method 2 ==* [[Open_Terminal|As root user logs into your HDA via ]] edit ''/etc/profile'' and add this to the bottom of the file:<pre>if [[Key-Based n "$SSH_CLIENT" ]; then TEXT="$(date): SSH Loginslogin to ${USER}@$(hostname -f)" TEXT="$TEXT from $(echo $SSH_CLIENT|Secure Shell (awk '{print $1}')" echo $TEXT|mail -s "SSH)]]Login" name@domain.comfi</pre> :'''NOTE:''' Ensure you replace name@domain.com with your email address.
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