1.查看日志文件
Linux查看/var/log/wtmp文件查看可疑IP登陸
last -f /var/log/wtmp
該日志文件永久記錄每個(gè)用戶登錄、注銷及系統(tǒng)的啟動(dòng)、停機(jī)的事件。因此隨著系統(tǒng)正常運(yùn)行時(shí)間的增加,該文件的大小也會(huì)越來(lái)越大,增加的速度取決于系統(tǒng)用戶登錄的次數(shù)。該日志文件可以用來(lái)查看用戶的登錄記錄,last命令就通過(guò)訪問(wèn)這個(gè)文件獲得這些信息,并以反序從后向前顯示用戶的登錄記錄,last也能根據(jù)用戶、終端tty或時(shí)間顯示相應(yīng)的記錄。
2.查看/var/log/secure文件尋找可疑IP登陸次數(shù)。
3.查看其他用戶的操作命令
(1)通過(guò)在/etc/profile里面加入以下代碼就可以實(shí)現(xiàn):
#cheke history command start!
PS1="`whoami`@`hostname`:"[$PWD]
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/historycommand ]
then
mkdir /tmp/historycommand
chmod 777 /tmp/historycommand
fi
if [ ! -d /tmp/historycommand/${LOGNAME} ]
then
mkdir /tmp/historycommand/${LOGNAME}
chmod 300 /tmp/historycommand/${LOGNAME}
fi
export HISTSIZE=4096
DT=`date "+%Y-%m-%d_%H:%M:%S"`
export HISTFILE="/tmp/historycommand/${LOGNAME}/${USER_IP} historycommand.$DT"
chmod 600 /tmp/historycommand/${LOGNAME}/*historycommand* 2>/dev/null
#the end
(2)source /etc/profile 使用腳本生效
(3)上面腳本在系統(tǒng)的/tmp新建個(gè)historycommand目錄,記錄所有登陸過(guò)系統(tǒng)的用戶和IP地址(文件名),每當(dāng)用戶登錄/退出會(huì)創(chuàng)建相應(yīng)的文件,該文件保存這段用戶登錄時(shí)期內(nèi)操作歷史,可以用這個(gè)方法來(lái)監(jiān)測(cè)系統(tǒng)的安全性。
