Arch Linux – 使用 logwatch

參考網頁:
Logwatch, SSMTP and Iptables or Arch Linux (Raspberry Pi) | Lisenet.com :: Linux | Security | Networking
Logwatch – ArchWiki
Linux 學習日誌: 學習使用 Logwatch (日誌檢視系統)

1. 安裝 syslog-ng
# pacman -S syslog-ng

2. 設定開機時啟動
# systemctl enable syslog-ng
啟動 syslog-ng
# systemctl start syslog-ng

3. 安裝 logwatch
# pacman -S logwatch[@more@]4. 安裝 ssmtp,利用 gmail 來寄信
# pacman -S ssmtp

5. 修改設定檔
# vim /etc/ssmtp/ssmtp.conf
#root=postmaster
# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and you mailhub is so named.
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
#rewriteDomain=y
# The full hostname
#hostname=root-chroot-copy
# 寄件者帳號
AuthUser=xxxx@gmail.com
# 寄件者密碼
AuthPass=xxxx
UseSTARTTLS=YES
FromLineOverride=yes #enables to use mail -r option

6. 更改檔案權限
# chmod 0600 /etc/ssmtp/ssmtp.conf

7. 修改設定檔 /etc/logwatch/conf/logwatch.conf
# echo “Detail = 5” > /etc/logwatch/conf/logwatch.conf
# echo “Output = mail” >> /etc/logwatch/conf/logwatch.conf
# echo “MailTo = xxxx@gmail.com” >> /etc/logwatch/conf/logwatch.conf
# echo “MailFrom = logwatch@arch.test.ilc.edu.tw” >> /etc/logwatch/conf/logwatch.conf