Changes

From Amahi Wiki
Jump to: navigation, search
577 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.
'''PREREQUISITE:''' 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 Reference: [http://linux.shalanstudio.hk/ssh_emailalert.htm Email Alert for 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.comfi</pre>
You should not get an :'''NOTE:''' Ensure you replace name@domain.com with your email anytime a user logs into your HDA via [[Key-Based SSH Logins|Secure Shell (SSH)]]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