shell: 如何设置 Linux 上 SSH 登录的 Email 提醒
June 4, 2015
你也可以选择性地让警告只对 root 用户生效:
-
[ root@vps ~]# vi . bashrc
将下面的内容添加到/root/.bashrc的尾部:
-
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
整个配置文件样例:
-
# .bashrc -
# User specific aliases and functions -
alias rm = ‘rm -i’ -
alias cp = ‘cp -i’ -
alias mv = ‘mv -i’ -
# Source global definitions -
if [ – f / etc / bashrc ]; then -
. / etc / bashrc -
fi -
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
0 Comments