web-dev-qa-db-ja.com

journalctlでauditdログを表示する

CentOS7を使用しています。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(153​​7383661.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 "hostname =? addr =? terminal = cron res = success '

type = CRED_DISP msg = audit(153​​7383661.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 "hostname =? addr =? terminal = cron res = success '

type = USER_END msg = audit(153​​7383661.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 "hostname =? addr =? terminal = cron res = success '

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. --

journalctlまたはauditdを構成して、journalctlaudit.logファイルから表示される出力を表示するにはどうすればよいですか?

1
kenlukas

そこにも一致するものは見つかりませんでした。それから私はこれをしました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を試してください。

1
Patrick Taylor