zoukankan      html  css  js  c++  java
  • Linux 监控root用户登录并发送邮件

    1、安装mailx

    yum  install  mailx -y

    2、配置/etc/mail.rc文件

    set from=yourname@126.com
    set smtp=smtps://smtp.126.com:465
    set smtp-auth-user=yourname@126.com
    set smtp-auth-password=n7876KhMpp8676uM
    set smtp-auth=login
    set ssl-verify=ignore
    set nss-config-dir=/root/.certs

    3、创建证书

    mkdir -p /root/.certs/
    echo -n | openssl s_client -connect smtp.126.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p‘ > ~/.certs/qq.crt
    certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
    certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
    certutil -L -d /root/.certs
    cd  /root/.certs
    certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt

    4、root用户的.bashrc 文件中添加告警脚本

    echo "$(whoami) login at: $(date +"%F %T") ip address: $(w|sed -n '3p'|awk '{print$3}')" | mail -s root yourmail@qq.com
  • 相关阅读:
    P1338 末日的传说
    P1364医院设置
    线程
    进程通信
    CentOS设置中文
    C++快读讲解
    迭代加深搜索
    P1118 [USACO06FEB]Backward Digit Sums G/S
    N皇后问题
    RMQ区间最值查询
  • 原文地址:https://www.cnblogs.com/husbandmen/p/10672624.html
Copyright © 2011-2022 走看看