加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 在ssh登录时发送电子邮件

发布时间:2020-12-15 18:23:25 所属栏目:安全 来源:网络整理
导读:我想确保每次有人登录我的服务器时都收到一封电子邮件说: 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
我想确保每次有人登录我的服务器时都收到一封电子邮件说:

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

在.bashrc中.

为什么我没有收到任何电子邮件?

谢谢你的帮助,J

当bash作为交互式非登录shell运行时执行.bashrc,而不是ssh时的情况.
在.bash_profile中添加相同的代码,该代码应该在shell是登录shell时运行

注意:许多发行版从.bash_profile中获取.bashrc,我可能错了,问题可能不是关于.bashrc / .bash_profile

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读