Skip to content Skip to main navigation Skip to footer

shell: 如何设置 Linux 上 SSH 登录的 Email 提醒

你也可以选择性地让警告只对 root 用户生效:

  1. [ root@vps ~]# vi . bashrc

将下面的内容添加到/root/.bashrc的尾部:

  1. echo ‘ALERT – Root Shell Access (vps.ehowstuff.com) on:’ `date` `who` | mail – s “Alert: Root Access from `who | cut -d'(‘ -f2 | cut -d’)’ -f1`>” recipient@gmail . com

整个配置文件样例:

  1. # .bashrc
  2. # User specific aliases and functions
  3. alias rm = ‘rm -i’
  4. alias cp = ‘cp -i’
  5. alias mv = ‘mv -i’
  6. # Source global definitions
  7. if [ – f / etc / bashrc ]; then
  8. . / etc / bashrc
  9. fi
  10. echo ‘ALERT – Root Shell Access (vps.ehowstuff.com) on:’ `date` `who` | mail – s “Alert: Root Access from `who | cut -d'(‘ -f2 | cut -d’)’ -f1`>” recipient@gmail . com

原文:http://www.linuxidc.com/Linux/2015-04/116726.htm

0 Comments

There are no comments yet

Leave a comment

Your email address will not be published.