SSH登录时向管理员发送邮件

首先去安装一个邮件服务

 

然后在~/.bash_profile文本中添加如下代码:

#!/bin/sh
echo "$USER@`hostname` login from ${SSH_CLIENT%% *} at $(date+%F' '%T)"|mail -s "Message for $USER login" test@163.com

source ~/.bash_profile

posted @ 2018-12-28 14:02  MegaloBox  阅读(203)  评论(0编辑  收藏  举报