- 安装邮件客户端
- 登陆预警
- 文件变动预警
安装邮件客户端
wget http://jaist.dl.sourceforge.net/project/msmtp/msmtp/1.6.5/msmtp-1.6.5.tar.xz
xz -d msmtp-1.6.5.tar.xz && tar xvf msmtp-1.6.5.tar && cd msmtp-1.6.5
./configure --prefix=/usr/local/msmtp
vi /root/.msmtprc
defaults
tls on
tls_starttls off
tls_trust_file /etc/pki/tls/certs/ca-bundle.crt
account default
host smtp.qq.com
port 465
auth on
user *****@qq.com
password nhxglkoynxfacafb
from *****@qq.com
logfile /usr/local/msmtp/msmtp.log
安装 mutt
yum install mutt
cp /etc/Muttrc /etc/Muttrc.bak && rm -rf /etc/Muttrc && ln /etc/Muttrc /root/.Muttrc && vi /etc/Muttrc
set sendmail="/usr/local/msmtp/bin/msmtp"
set use_from=yes
set realname="*****@qq.com"
添加 /root/.bashrc ## root 用户环境变量
USERSSSS=`whoami`
TIMESSA=`date -d today +"%Y-%m-%d %T"`
USERS_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
INFO999="正在登陆通过"
INFO998="通过"
INFO997="警告"
SERVER_IP=`ifconfig eno1 | grep "inet 19" | awk '{ print $2}'`
echo $TIMESSA $INFO997 $USERS_IP $INFO998 $USERSSSS $INFO999 $SERVER_IP | mutt -s "服务器预警" ****@qq.com