Linux系統(tǒng)下的用戶審計(jì)方法
創(chuàng)建審計(jì)日志目錄
創(chuàng)建用戶審計(jì)日志文件;
將文件賦予低權(quán)限用戶
賦予所有人寫權(quán)限
賦予所有用戶追加權(quán)限
編輯/etc/profile 增加以下內(nèi)容;
export PROMPT_COMMAND='{ date "+%y-%m-%d %T ##### $(who am i |awk "{print \$1\" \"\$2\" \"\$5}")
實(shí)例
多人共同使用的服務(wù)器權(quán)限確實(shí)不好管理,誤操作等造成故障,無法追究,最好的辦法就是將用戶操作實(shí)時(shí)記錄到日志,并推送到遠(yuǎn)程日志服務(wù)器上。包括(用戶登陸時(shí)間,目錄,操作命令及時(shí)間戳等)。以便事后追查。
環(huán)境:centos5.5 X86_64 2臺(tái) #備注:把兩臺(tái)主機(jī)的防火墻和selinux關(guān)閉。在進(jìn)行操作。
(一)日志服務(wù)器IP:10.0.2.164
(二)客戶端服務(wù)器IP:10.0.2.165
1.先在日志服務(wù)器10.0.2.164主機(jī)上操作:
#配置日志保存文件,把該文件第一行的*.info 提出來。單獨(dú)放一行。
[root@MySQL-B ~]# service syslog restart #重啟syslog日志服務(wù)。
Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
[root@MySQL-B ~]# vim /etc/sysconfig/syslog #接收客戶端寫入。
把SYSLOGD_OPTIONS="-m 0" 更改為:SYSLOGD_OPTIONS="-m 1 -r"
2.然后在客戶端服務(wù)器10.0.2.165主機(jī)上操作:
export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });logger "[euid=$(whoami)]":$(who am i):[`pwd`]"$msg"; }'
[root@MySQL-A ~]# source /etc/profile #重新手動(dòng)source更新。
2.1.客戶機(jī)修改日志服務(wù)器10.0.2.165主機(jī)上操作:
[root@MySQL-A ~]# echo "*.info@logserver" >> /etc/syslog.conf
#將info日志推送到日志服務(wù)器,把該文件第一行的*.info 提出來。單獨(dú)放一行。
[root@MySQL-A ~]# /etc/init.d/syslog restart#重啟syslog日志。
Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
3.測(cè)試,在客戶端主機(jī)上10.0.2.165主機(jī)上測(cè)試并操作:
[root@MySQL-A ~]# echo "this is a test 1"
this is a test 1
[root@MySQL-A ~]# echo "this is a test 2"
this is a test 2
[root@MySQL-A ~]# echo "this is a test 3"
this is a test 3
[root@MySQL-A ~]# echo "this is a test 4"
this is a test 4
[root@MySQL-A ~]# echo "this is a test 5"
this is a test 5
4.返回日志服務(wù)器10.0.2.164主機(jī)上看結(jié)果,是否記錄下來客戶端主機(jī)執(zhí)行的操作?
Apr 6 10:37:55 10.0.2.165 root: [euid=root]:root pts/1 Apr 6 10:37 (10.0.2.188):[/root]echo "this is a test1"
Apr 6 10:37:59 10.0.2.165 root: [euid=root]:root pts/1 Apr 6 10:37 (10.0.2.188):[/root]echo "this is a test2"
Apr 6 10:38:01 10.0.2.165 root: [euid=root]:root pts/1 Apr 6 10:37 (10.0.2.188):[/root]echo "this is a test3"
Apr 6 10:38:04 10.0.2.165 root: [euid=root]:root pts/1 Apr 6 10:37 (10.0.2.188):[/root]echo "this is a test4"
Apr 6 10:38:06 10.0.2.165 root: [euid=root]:root pts/1 Apr 6 10:37 (10.0.2.188):[/root]echo "this is a test5"
返回參數(shù)分別為:#操作時(shí)間 #操作IP #有效用戶 #實(shí)際登陸時(shí)間 #路徑 #使用的命令
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信