Linux

在 journalctl 中查看審核的日誌

  • September 20, 2018

我正在使用 CentOS 7。試圖查看auditd登錄journalctl

當我嘗試時,journalctl -u auditd我看到以下輸出:

-- Logs begin at Wed 2018-09-05 08:59:19 EDT, end at Wed 2018-09-19 15:01:01 EDT. --
Sep 05 12:59:25 centos7 systemd[1]: Starting Security Auditing Service...
Sep 05 12:59:25 centos7 auditd[563]: Started dispatcher: /sbin/audispd pid: 565
Sep 05 12:59:25 centos7 audispd[565]: No plugins found, exiting
Sep 05 12:59:25 centos7 auditd[563]: Init complete, auditd 2.8.1 listening for events (startup state enable)
Sep 05 12:59:25 centos7 augenrules[567]: /sbin/augenrules: No change
Sep 05 12:59:25 centos7 augenrules[567]: No rules
Sep 05 12:59:25 centos7 augenrules[567]: enabled 1
Sep 05 12:59:25 centos7 augenrules[567]: failure 1
Sep 05 12:59:25 centos7 augenrules[567]: pid 563
Sep 05 12:59:25 centos7 augenrules[567]: rate_limit 0
Sep 05 12:59:25 centos7 augenrules[567]: backlog_limit 8192
Sep 05 12:59:25 centos7 augenrules[567]: lost 0
Sep 05 12:59:25 centos7 augenrules[567]: backlog 1
Sep 05 12:59:25 centos7 augenrules[567]: enabled 1
Sep 05 12:59:25 centos7 augenrules[567]: failure 1
Sep 05 12:59:25 centos7 augenrules[567]: pid 563
Sep 05 12:59:25 centos7 augenrules[567]: rate_limit 0
Sep 05 12:59:25 centos7 augenrules[567]: backlog_limit 8192
Sep 05 12:59:25 centos7 augenrules[567]: lost 0
Sep 05 12:59:25 centos7 augenrules[567]: backlog 1
Sep 05 12:59:25 centos7 systemd[1]: Started Security Auditing Service.

這就是它結束的地方。

如果我執行,tail -3 /var/log/audit/audit.log我會看到我期望的輸出:

type=CRED_REFR msg=audit(1537383661.096:4863): pid=13894 uid=0 auid=0 ses=567 msg=‘op=PAM:setcred grantors=pam_env,pam_faillock,pam_unix acct=“root” exe="/usr/ sbin/crond" 主機名=? 地址=?終端=cron res=成功’

type=CRED_DISP msg=audit(1537383661.107:4864): pid=13894 uid=0 auid=0 ses=567 msg=‘op=PAM:setcred grantors=pam_env,pam_faillock,pam_unix acct=“root” exe="/usr/ sbin/crond" 主機名=? 地址=?終端=cron res=成功’

type=USER_END msg=audit(1537383661.109:4865): pid=13894 uid=0 auid=0 ses=567 msg=‘op=PAM:session_close grantors=pam_loginuid,pam_keyinit,pam_limits,pam_systemd acct=“root” exe="/ usr/sbin/crond" 主機名=? 地址=?終端=cron res=成功’

我查看了來自https://major.io/2017/01/05/display-auditd-messages-with-journalctl/的說明

從那個頁面執行這個命令給了我這個輸出,然後等待(如預期的那樣)。

$ journalctl -af _TRANSPORT=audit
-- Logs begin at Wed 2018-09-05 08:59:19 EDT. --

如何配置journalctlauditd查看我從audit.log文件中看到的輸出journalctl

我也沒有在那裡找到任何匹配項。然後我這樣做了 journalctl _TRANSPORT=syslog,發現我確實有匹配項。這導致我進行了一些調查,我發現如果我過濾特定的東西,例如sshd,我會找到匹配項,儘管它們看起來完全不同。這是一個實際的例子:

audit.log : type=CRED_REFR msg=audit(1537414472.742:270819): pid=20227 uid=0 auid=0 ses=30399 msg='op=PAM:setcred grantors=pam_env,pam_unix acct="root" exe="/usr/sbin/sshd" hostname=130.19.106.234 addr=130.19.106.234 terminal=ssh res=success'
journalctl _TRANSPORT=syslog | grep sshd | tail

輸出

Sep 19 20:34:32 ndc1ascem2rad1.eng.mobilephone.net sshd[20225]: Accepted publickey for root from 130.19.106.234 port 60853 ssh2: RSA 00:7e:b4:44:05:c0:fa:e3:xxxxxxxxxxxxxxxxxxxxxx
Sep 19 20:34:32 ndc1ascem2rad1.eng.mobilephone.net sshd[20225]: pam_unix(sshd:session): session opened for user root by (uid=0)

請注意 IP 地址匹配。所以嘗試 _TRANSPORT=syslog 代替。

引用自:https://serverfault.com/questions/931752