sudo tail -f /var/log/auth.log | while read line; do id=$((id+1)); if [[ $id -gt 10 ]]; then if [[ `echo $line | awk '{print $5}' | awk -F [ '{print $1}'` == "sshd" ]]; then if [[ `echo $line | awk '{print $6}'` == Failed ]]; then dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"`echo $line | awk '{print $9}'` failed to log in to SSH from `echo $line | awk '{print $11}'`"; else if [[ `echo $line | awk '{print $6}'` == Accepted ]]; then dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"`echo $line | awk '{print $9}'` succefully logged in to SSH from `echo $line | awk '{print $11}'`"; else if [[ `echo $line | awk '{print $6}'` == Received ]] && [[ `echo $line | awk '{print $7}'` == disconnect ]]; then dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"`echo $line | awk '{print $9}' | awk -F : '{print $1}'` disconnected from SSH"; fi fi fi fi fi done
ip="" sudo tail -f /var/log/auth.log | while read line; do id=$((id+1)); if [[ $id -gt 10 ]]; then if [ -n "$ip" ]; then notify-send "SSH Notifier" "`echo $line | awk '{print $11}'` disconnected from SSH from $ip!"; ip="" else if [[ `echo $line | awk '{print $5}'` == sshd* ]]; then if [[ `echo $line | awk '{print $6}'` == Failed ]]; then notify-send "SSH Notifier" "`echo $line | awk '{print $9}'` failed to log in to SSH from `echo $line | awk '{print $11}'`!"; else if [[ `echo $line | awk '{print $6}'` == Accepted ]]; then notify-send "SSH Notifier" "`echo $line | awk '{print $9}'` succefully logged in to SSH from `echo $line | awk '{print $11}'`!"; else if [[ `echo $line | awk '{print $6}'` == Received ]] && [[ `echo $line | awk '{print $7}'` == disconnect ]]; then ip=`echo $line | awk '{print $9}' | awk -F : '{print $1}'` fi fi fi fi fi fi done