Skip to content

Instantly share code, notes, and snippets.

@korovamilk
Last active August 29, 2015 14:17
Show Gist options
  • Save korovamilk/4d343cffccaf6a98f517 to your computer and use it in GitHub Desktop.
Save korovamilk/4d343cffccaf6a98f517 to your computer and use it in GitHub Desktop.

Revisions

  1. korovamilk revised this gist Mar 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion alert_user_login.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ### add this to .bashrc
    DEST_EMAIL="[email protected]"
    TMPCOOKIE="/tmp/cookie.$(date +%y%m%d%H%M%S)""
    TMPCOOKIE="/tmp/cookie.$(date +%y%m%d%H%M%S)"
    CONNIP=$(echo $SSH_CONNECTION | cut -d " " -f 1)
    touch ${TMPCOOKIE}
    if [ -z "$CONNIP" ]
  2. korovamilk revised this gist Mar 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion alert_user_login.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    ### add this to .bashrc
    DEST_EMAIL="[email protected]"
    TMPCOOKIE="/tmp/cookie.$(date +%y%m%d%H%M%S)""
    CONNIP=${echo $SSH_CONNECTION | cut -d " " -f 1}
    CONNIP=$(echo $SSH_CONNECTION | cut -d " " -f 1)
    touch ${TMPCOOKIE}
    if [ -z "$CONNIP" ]
    then
  3. korovamilk created this gist Mar 17, 2015.
    19 changes: 19 additions & 0 deletions alert_user_login.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    ### add this to .bashrc
    DEST_EMAIL="[email protected]"
    TMPCOOKIE="/tmp/cookie.$(date +%y%m%d%H%M%S)""
    CONNIP=${echo $SSH_CONNECTION | cut -d " " -f 1}
    touch ${TMPCOOKIE}
    if [ -z "$CONNIP" ]
    then
    echo "${HOSTNAME}: User $USER just logged in from console" >> ${TMPCOOKIE}
    echo >> ${TMPCOOKIE}
    w >> ${TMPCOOKIE}
    mail -s "ssh login at ${HOSTNAME}" ${DEST_EMAIL} < ${TMPCOOKIE}
    rm -f ${TMPCOOKIE}
    else
    echo "${HOSTNAME}: User $USER just logged in from $CONNIP" >> ${TMPCOOKIE}
    echo >> ${TMPCOOKIE}
    w >> ${TMPCOOKIE}
    mail -s "ssh login at ${HOSTNAME}" ${DEST_EMAIL} < ${TMPCOOKIE}
    rm -f ${TMPCOOKIE}
    fi