$ yum install mailx
新增 Email 通知的 sell script
$ vi /etc/vsftpd/email_script.shemail_script.sh 內容
#!/bin/bash [ "$PAM_TYPE" = "open_session" ] || exit 0 { echo "User: $PAM_USER" echo "Ruser: $PAM_RUSER" echo "Rhost: $PAM_RHOST" echo "Service: $PAM_SERVICE" echo "TTY: $PAM_TTY" echo "Date: `date`" echo "Server: `uname -a`" } | mail -S "from=vsftpd<vsftpd@example.com>" -s "`hostname -s` $PAM_SERVICE login: $PAM_USER" xyz@example.com修改為可執行
$ chmod +x /etc/vsftpd/email_script.sh
使用PAM session機制,在登入時,執行發信的email_script.sh
$ vi /etc/pam.d/vsftpd新增
session optional pam_exec.so /etc/vsftpd/email_script.sh
修改 vsftpd.conf,開啟 session_support,PAM 中 vsftpd 設定的 session 才會有效
$ vi /etc/vsftpd/vsftpd.conf新增
session_support=YES
重新啟動vsftpd
$ systemctl restart vsftpd
登陸Linux伺服器時觸發郵件提醒 - IT閱讀
linux - Using pam_exec.so to run a script as root when a user logs in (while extracting user information)? - Unix & Linux Stack Exchange
pam - How to configure vsftpd to send me an email on user login process? - Stack Overflow
FTP (Vsftp) log 設定說明 | FAQ Book
沒有留言:
張貼留言