使用原始用户名记录所有 root 活动,该用户名 su'd/sudoed to root

Gre*_*hal 11 root logs

当 root 登录被禁用 (SSH) 但用户可以运行sudo -isu -成为 root时,跟踪谁在日志中充当 root 的首选方法是什么?我也想使用原始用户名执行每个命令。RHEL 6 或任何 Linux rsyslog 等。

小智 8

最强大的方法似乎被审计了:

要求 10:跟踪和监控对网络资源和持卡人数据的所有访问

Auditd 基本上会拦截所有系统调用并根据您的规则集进行检查。因此,在您的/etc/audit/audit.rules文件中,您将具有以下内容:

# This file contains the auditctl rules that are loaded
# whenever the audit daemon is started via the initscripts.
# The rules are simply the parameters that would be passed
# to auditctl.

# First rule - delete all
-D

# Increase the buffers to survive stress events.
# Make this bigger for busy systems
-b 320

# Feel free to add below this line. See auditctl man page
-a always,exit -F euid=0 -F perm=wxa -k ROOT_ACTION
Run Code Online (Sandbox Code Playgroud)

最后一条规则是唯一的非默认规则。

这种方法的主要缺点(也是我在寻找替代方案时发现这个问题的原因)是原始日志文件非常神秘,只有在原始日志文件上运行查询程序后才有用: ausearch

该规则的示例查询是:

ausearch -ts today -k ROOT_ACTION -f audit_me | aureport -i -f
Run Code Online (Sandbox Code Playgroud)

一个常识性的解决方案可能是创建一个 cron 来查询您的原始审计日志,然后将它们发送到您的日志记录解决方案。


slm*_*slm 5

在 Red Hat 发行版上,您通常使用/var/log/secure日志来识别谁正在登录或使用sudoFedora/CentOS/RHEL 系统。

例子

须藤示例
$ sudo -Es
Run Code Online (Sandbox Code Playgroud)

日志结果:

9 月 1 日 19:32:51 greeneggs sudo: saml : TTY=pts/2 ; PWD=/home/saml ;用户=根;命令=/bin/bash

苏的例子
$ su -
Run Code Online (Sandbox Code Playgroud)

日志结果:

Sep 1 19:34:49 greeneggs su: pam_unix(su-l:session): saml(uid=1000) 为用户 root 打开的会话