我想确保每当有人登录我的服务器时,我会收到一封电子邮件说:
ALERT Shell Access on:Tue Jun 16 11:04:10 CDT 2009 user123 pts / 0 2009-06-16 11:04
所以我把这段代码:
echo 'ALERT Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" example@example.com
<{1>}中的。
为什么我没有收到任何电子邮件?
感谢您的帮助,J
答案 0 :(得分:11)
注意:许多发行版从.bash_profile中获取.bashrc,我可能错了,问题可能不是关于.bashrc / .bash_profile
答案 1 :(得分:0)
加入/etc/ssh/sshrc
ip=`echo $SSH_CONNECTION | cut -d " " -f 1`
logger -t ssh-wrapper $USER login from $ip
msg="User $USER just logged in from $ip"
echo $msg|mail -s $msg root