Instructions
-
Install python3
1yum install -y python3 python3-pip -
Install send mail module
1 2 3 4 5 6#In centos or ubuntu pip3 install --index-url https://nexus.xethh.me/repository/pypi/simple --upgrade XSysLogSendmail #In some case in rasbian #pip and pip3 get messaged pip3 install --index-url https://nexus.xethh.me/repository/pypi/simple --upgrade XSysLogSendmail -
Open python3 repl, send genZohoAuthenLogMail to generate a send mail script on current directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15python3 ========= import XSysLogSendmail XSysLogSendmail.genZohoAuthenLogMail() **Current directory is /data/scripts, confirm? [Enter] **Please enter smtp host: [Smtp Account] **Please enter smtp pwd: [Smtp Password] **Please enter sender: [Send address] **Please enter receiver: [Receiver addresses separated by comma] -
add below line to
/etc/pam.d/sshd1 2 3 4#Based on the blog post, it suggest to use require #But to my understanding, the script maybe have change return error, which will lead to fail authen #So i would like to use optional instead, the operation will perceed, but result ignored session optional pam_exec.so {path to sh file} -
After generated the file, change modification permission
1chmod +x sendmail.sh -
Temporary disable selinux if needed, will fix this in the future [Link]
1 2setenforce 0 #setenforce 1 ==> set enable