Skip to main content
Menu
mail | Cheatsheets
mail

Monitor and Alert SSH Login Activty

September 3, 2021
linux, mail
devops, monitoring

Edit sshrc file # vi /et/ssh/sshrc Add following lines ip=`echo $SSH_CONNECTION | cut -d " " -f 1` logger -t ssh-wrapper $USER login from $ip echo "User $USERjust logged in from $ip" | mail -s "[ATTENTION] $USERJust logged in from $ip" your-email@your-domain.com Monitor your ssh authorized_keys changes # create notify.sh script file and add following code of lines #!/bin/bash [[ -z `find /home/ubuntu/.ssh/authorized_keys -mmin -1` ]] if [ $? ...

Configure SMTP with Gmail Using Postfix

September 3, 2021
linux, mail
devops, monitoring

Setup Google App password # Go account security https://myaccount.google.com/security Create App Password Select App as Mail Select Device (other) > name your system Generate Note down Generated password Install all necessary packages # sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules Edit postfix config file # vi /etc/postfix/main.cf and following lines to it: relayhost = [smtp.gmail.com]:587 smtp_tls_security_level = may smtp_sasl_auth_enable = yes smtp_sasl_security_options = smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_use_tls = yes mydestination = inet_protocols = ipv4 Edit sasl_passwd file # vi /etc/postfix/sasl_passwd add gmail username and generate password ...