linux远程ssh登陆用户的操作记录
2013-08-30 14:05
417 查看
在/etc/profile配置文件的末尾加入以下脚本代码,或者单独生成一个文件,置于/etc/profile.d/目录下,实现SSH远程登陆用户IP地址和终端操作的日志记录。
history
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 /tmp/history ]
then
mkdir /tmp/history
chmod 777 /tmp/history
fi
if [ ! -d /tmp/history/${LOGNAME} ]
then
mkdir /tmp/history/${LOGNAME}
chmod 300 /tmp/history/${LOGNAME}
fi
export HISTSIZE=4096
DT=`date +"%Y%m%d_%H%M%S"`
export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP} history.$DT"
chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null
本文出自 “WHY” 博客,请务必保留此出处http://wangyh.blog.51cto.com/951648/1285673
history
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 /tmp/history ]
then
mkdir /tmp/history
chmod 777 /tmp/history
fi
if [ ! -d /tmp/history/${LOGNAME} ]
then
mkdir /tmp/history/${LOGNAME}
chmod 300 /tmp/history/${LOGNAME}
fi
export HISTSIZE=4096
DT=`date +"%Y%m%d_%H%M%S"`
export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP} history.$DT"
chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null
本文出自 “WHY” 博客,请务必保留此出处http://wangyh.blog.51cto.com/951648/1285673
相关文章推荐
- 通过登陆IP记录Linux所有用户登录所操作的日志
- linux系统新建用户ssh远程登陆显示-bash-4.1$解决方法
- linux系统新建用户ssh远程登陆显示-bash-4.1$解决方法,ssh-bash-4.1
- Linux下查看用户登陆后的操作记录及history命令显示时间
- 通过登陆IP记录Linux所有用户登录所操作的日志
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录
- 通过登陆IP记录Linux所有用户登录所操作的日志
- Linux下查看用户登陆后的操作记录的方法
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录
- 通过登陆IP记录Linux所有用户登录所操作日志的方法
- linux系统新建用户ssh远程登陆显示-bash-4.1$解决方法
- Linux下查看用户登陆后的操作记录及history命令显示时间
- Linux下查看用户登陆后的操作记录
- Linux下查看用户登陆后的操作记录
- Linux下查看用户登陆后的操作记录
- Linux下查看用户登陆后的操作记录