将登录用户执行的命令重定向到特定目录-用于安全审计

#############################################################
unset MAILCHECK
history
USER=`whoami`
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]; then
USER_IP=`hostname`
fi
if [ ! -d /var/log/.history ]; then
mkdir /var/log/.history
chmod 777 /var/log/.history
fi
if [ ! -d /var/log/.history/${LOGNAME} ]; then
mkdir /var/log/.history/${LOGNAME}
chmod 300 /var/log/.history/${LOGNAME}
fi
export HISTSIZE=4096
DT=`date +"%Y%m%d_%H:%M:%S"`
export HISTFILE="/var/log/.history/${LOGNAME}/${USER}@${USER_IP}_$DT"
chmod 600 /var/log/.history/${LOGNAME}/*history* 2>/dev/null
#############################################################
声明:本文为原创,作者为 辣条①号,转载时请保留本声明及附带文章链接:https://boke.wsfnk.com/archives/40.html
谢谢你请我吃辣条谢谢你请我吃辣条

如果文章对你有帮助,欢迎点击上方按钮打赏作者

最后编辑于:2022/12/3作者: 辣条①号

现在在做什么? 接下来打算做什么? 你的目标什么? 期限还有多少? 进度如何? 不负遇见,不谈亏欠!

暂无评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

arrow grin ! ? cool roll eek evil razz mrgreen smile oops lol mad twisted wink idea cry shock neutral sad ???