国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux系統下的用戶審計方法

2020-07-10 11:18:26
字體:
來源:轉載
供稿:網友

創建審計日志目錄
 

復制代碼
代碼如下:
mkdir -p /var/log/user_audit

創建用戶審計日志文件;
 

復制代碼
代碼如下:
touch /var/log/user_audit/user_audit.log

將文件賦予低權限用戶
 

復制代碼
代碼如下:
chown nobody:nobody /var/log/user_audit/user_audit.log

賦予所有人寫權限
 

復制代碼
代碼如下:
chmod 002 /var/log/user_audit/user_audit.log

賦予所有用戶追加權限
 

復制代碼
代碼如下:
chattr +a /var/log/user_audit.log

編輯/etc/profile 增加以下內容;
 

復制代碼
代碼如下:
export HISTORY_FILE=/var/log/user_audit/user_audit.log
export PROMPT_COMMAND='{ date "+%y-%m-%d %T ##### $(who am i |awk "{print /$1/" /"/$2/" /"/$5}")

實例
多人共同使用的服務器權限確實不好管理,誤操作等造成故障,無法追究,最好的辦法就是將用戶操作實時記錄到日志,并推送到遠程日志服務器上。包括(用戶登陸時間,目錄,操作命令及時間戳等)。以便事后追查。
環境:centos5.5 X86_64 2臺              #備注:把兩臺主機的防火墻和selinux關閉。在進行操作。
(一)日志服務器IP:10.0.2.164
(二)客戶端服務器IP:10.0.2.165
1.先在日志服務器10.0.2.164主機上操作:

復制代碼
代碼如下:
[root@MySQL-B ~]# echo "*.info /var/log/client" >> /etc/syslog.conf
#配置日志保存文件,把該文件第一行的*.info 提出來。單獨放一行。
[root@MySQL-B ~]# service syslog restart #重啟syslog日志服務。
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.然后在客戶端服務器10.0.2.165主機上操作:

復制代碼
代碼如下:
[root@MySQL-A ~]# vim /etc/profile #添加如下行。
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 #重新手動source更新。

2.1.客戶機修改日志服務器10.0.2.165主機上操作:

復制代碼
代碼如下:
[root@MySQL-A ~]# echo "10.0.2.164 logserver" >> /etc/hosts #日志服務器地址。
[root@MySQL-A ~]# echo "*.info @logserver" >> /etc/syslog.conf
#將info日志推送到日志服務器,把該文件第一行的*.info 提出來。單獨放一行。
[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.測試,在客戶端主機上10.0.2.165主機上測試并操作:                     

復制代碼
代碼如下:
[root@MySQL-A ~]# test
[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.返回日志服務器10.0.2.164主機上看結果,是否記錄下來客戶端主機執行的操作?

復制代碼
代碼如下:
[root@MySQL-B ~]# cat /var/log/client
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"

返回參數分別為:#操作時間  #操作IP  #有效用戶  #實際登陸時間  #路徑  #使用的命令

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 白山市| 台湾省| 扎兰屯市| 宜宾市| 江川县| 卢龙县| 崇阳县| 襄汾县| 蒙山县| 安国市| 长宁区| 扶余县| 娱乐| 文安县| 金湖县| 宁国市| 嵊州市| 克什克腾旗| 寻乌县| 蒙山县| 七台河市| 高清| 龙口市| 防城港市| 望江县| 衡东县| 西宁市| 无锡市| 会昌县| 信阳市| 环江| 密云县| 平利县| 琼中| 伊春市| 广南县| 休宁县| 南丹县| 阳高县| 公安县| 十堰市|