Answers:
对于有人登录您的系统时的通知部分,您可以尝试在脚本中放入一个小/etc/profile.d脚本。使用notify-send(libnotify-bin软件包的一部分),您可以尝试以下操作:
/etc/profile.d/notify_log.sh
notify-send -t 3000 "User logged in" `whoami`
然后,每次有人登录您的系统时,您都会收到通知。
编辑:因此,它不能很好地工作:(如果您在计算机上配置了邮件服务器,则可以使用mail命令代替notify-send。
/etc/profile.d/是源文件。只有登录shell(虚拟终端和ssh登录)和某些GUI登录才执行配置文件初始化。
source /etc/profile.d/notify_log.sh通过ssh登录后,则发送通知。我猜它登录后执行不正确。我观察到/var/log/auth.log没有运气。有什么帮助吗?
我们通过创建/etc/profile.d/notify.sh具有以下内容的文件来做到这一点:
#!/bin/sh
sender="hostname@example.com"
recepient="admingroup@example.com"
subject="Privileged Account logon used"
message="`env`"
echo "$message" | mail -s "$subject" -r "$sender" -Smtp=mail.example.com "$recepient"
假设已安装mailx。