Configure Audit Service To Send Audit Messages To Another Server
Configure Audit Service To Send Audit Messages To Another Server
Server
Posted on 23/06/2019 by Lisenet
The auditd service does not include the ability to send audit records to a centralised server for management directly.
It does include a plug-in for audit event multiplexor to pass audit records to a remote syslog server.
Homelab Setup
We have two servers in our homelab:
name_format = HOSTNAME
Open /etc/audisp/plugins.d/au-remote.conf for editing and set the value for the active option to yes:
active = yes
Open /etc/audisp/audisp-remote.conf for editing and set configuration for the remote logging server:
remote_server = server2.hl.local
port = 60
# firewall-cmd --reload
Log out and log back in to the server1. Check the log file on server2:
This short note explains steps to direct audit logs to remote rsyslog server on a
CentOS/RHEL 6,7 Server.
# vi /etc/rsyslog.conf
$ModLoad imtcp
$InputTCPServerRun 514
If you are using UDP then uncomment following lines:
# vi /etc/rsyslog.conf
$ModLoad imudp
$UDPServerRun 514
2. Configure the rsyslog server to recieve rsyslog events from client. To receive
audit logs from client servers, add below lines in the /etc/rsyslog.conf file:
# vi /etc/rsyslog.conf
$template HostAudit, "/var/log/rsyslog/%HOSTNAME%/audit_log"
local6.* ?HostAudit
3. Restart the rsyslog service.
# service rsyslog restart ### CentOS/RHEL 6
# systemctl restart rsyslog ### CentOS/RHEL 7
# cp /etc/rsyslog.conf /etc/rsyslog.conf.bkp
2. Append the following rules to the /etc/rsyslog.conf file for directing the logs to
central rsyslog server. “imfile” module has to be loaded on the rsyslogd, otherwise
the configuration for directing the auditd log won’t work.
# vi /etc/rsyslog.conf
#audit log
$ModLoad imfile
$InputFileName /var/log/audit/audit.log
$InputFileTag tag_audit_log:
$InputFileStateFile audit_log
$InputFileSeverity info
$InputFileFacility local6
$InputRunFileMonitor
Server: 192.168.241.140
Client: 172.31.21.58
How to Install and Configure Rsyslog Server
Most Linux distributions come with the rsyslog package preinstalled. In case it’s
not installed, you can install it using your Linux package manager tool as shown.
Once rsyslog installed, you need to start the service for now, enable it to auto-
start at boot and check it’s status with the systemctl command.
$ModLoad imudp
$UDPServerRun 514
$InputTCPServerRun 514
In this case, we want to use both UDP and TCP connections at the same time.
Configure
Rsyslog Logging Server
Next, you need to define the ruleset for processing remote logs in the following
format.
Where:
*.* ?RemoteLogs
& ~
If the system has firewall enabled, you need to open port 514 to allow
both UDP/TCP connections to the rsyslog server, by running.
If it’s not installed, install it and start the service as shown earlier on.
Once the rsyslog service is up and running, open the main configuration file
where you will perform changes to the default configuration.
$ sudo vim /etc/rsyslog.conf
To force the rsyslog daemon to act as a log client and forward all locally
generated log messages to the remote rsyslog server, add this forwarding rule, at
the end of the file as shown in the following screenshot.
*. * @@192.168.100.10:514
The above rule will send messages from all facilities and at all severity levels. To
send messages from a specific facility for example auth, use the following rule.
auth. * @@192.168.100.10:514
Save the changes and close the configuration file. To apply the above settings,
restart the rsyslog daemon.
$ sudo systemctl restart rsyslog
$ ls -l /var/log/
If the directory exists, check the log files inside it, by running.
$ sudo ls -l /var/log/ip-172-31-21-58/
Check Rsyslog Client Logs
Summary
Rsyslog is a high-performance log processing system, designed in a
client/server architecture. We hope you are able to install and
configure Rsyslog as a central/network logging server and as a client as
demonstrated in this guide.
Details
The following log files are located in the /var/log/ directory and while this list is
comprehensive, it is by no means every possible log file that can exist in this location.
The logs are managed by the syslog facility and the various facilities can log to one or more
of the log files listed. In addition, the user can turn off logging of a specific facility.
The facilities are typically:
kern.*
*.info
mail.*
authpriv.*
cron.*
*.emerg
These are set up, on a RHEL system in /etc/syslog.conf file.
Here are a list of the log files and what they mean or do:
/var/log/messages - This file has all the global system messages located inside,
including the messages that are logged during system startup. Depending on how the
syslog config file is sent up, there are several things that are logged in this file including
mail, cron, daemon, kern, auth, etc.
/var/log/dmesg - Contains kernel ring buffer. This file is overwritten when the system is
rebooted.
/var/log/auth.log - System authorization information is included in this file, along with
user logins and the authentication mechanism that were used.
/var/log/boot.log - Contains information that are logged when the system boots
/var/log/daemon.log - The various system background daemons that are running will log
information to this file.
/var/log/kern.log - Contains information logged by the kernel. Helpful to troubleshoot a
custom-built kernel.
/var/log/lastlog - Displays the recent login information for all the users. This is not an
ascii file. An admin can use the lastlog command to view the content of this file.
/var/log/maillog /var/log/mail.log - Logs information from the mail server that is
running on the system. For example, sendmail logs information about all the sent items to
this file.
/var/log/user.log - Contains information about all user level logs.
/var/log/Xorg.x.log - Log messages from the X server to this file.
/var/log/btmp - This file contains information about failed login attempts. Use the last
command to view the btmp file. For example, last -f /var/log/btmp | more.
/var/log/cups /var/log/spooler - All printer and printing related log messages.
/var/log/anaconda.log - While installing Linux, all installation related messages are
stored in this log file.
/var/log/yum.log - Contains information that are logged when a package is installed
using yum. This file can be referenced in the event a packages is removed that has
dependencies.
/var/log/cron - Whenever cron daemon (or anacron) starts a cron job, it logs the
information about the cron job in this file
/var/log/secure - Contains information related to authentication and authorization
privileges. For example, sshd logs all the messages here, including unsuccessful login.
/var/log/wtmp - The wtmp file records all logins and logouts.
/var/log/utmp - The utmp file allows one to discover information about who is currently
using the system.
/var/log/faillog - Contains failed user login attempts. Use faillog command to display the
content of this file.
/var/log/httpd/ - Contains the apache web server access_log and error_log and related
virtual hosts logs if set up to log here.
/var/log/apache2 - Contains the apache web server access_log and error_log and related
virtual hosts logs if set up to log here.
/var/log/conman/ - Log files for ConMan client. conman connects remote consoles that
are managed by conmand daemon.
/var/log/mail/ - This subdirectory contains additional logs from the mail server. For
example, sendmail stores the collected mail statistics in /var/log/mail/statistics file
/var/log/audit/ - Contains logs information stored by the Linux audit daemon (auditd).
/var/log/setroubleshoot/ - SELinux uses setroubleshootd (SE Trouble Shoot Daemon) to
notify about issues in the security context of files and logs those information in this log file.
/var/log/samba/ - Contains log information stored by samba, which is used to connect
Windows to Linux.
/var/log/sa/ - Contains the daily sar files that are collected by the sysstat package.
Overview
For RHEL7.
*.* @@xxx.xxx.xxx.xxx:10514
And now journald.conf, the default is ”RateLimitInterval=30s” and
”RateLimitBurst=1000”, I had to change this as I was seeing dropped journalctl
messages – ”journal: Suppressed 10361 messages from”. I had to exclude
”/var/lib/rsyslog” in audit.rules as it was creating thousands of messages, i.e. a logging
loop. It is possible that rsyslog can drop messages as well, they will show up as
”imjournal: begin to drop messages due to rate-limiting”, to rate-limit rsyslog you make
changes the rsyslog.conf file.
RateLimitInterval=15s
RateLimitBurst=3000
If you need to rate-limit rsyslog to can add the following, however, I’ve not tested this.
tail -f /var/log/messages
From a second shell
journalctl -f
From a third shell generate some traffic
From an Operating system research point of view, Windows is not certainly old
stuff, and it’s clear that people should be looking beyond it. After the launch of
Linux, which is expected to govern the world in a few years, a sudden shift
occurred. Because Linux OS is free, it is used by the majority of businesses.
Even small businesses are adapting the Linux operating system.
It’s for mail server logs, which can be useful for postfix,
/var/log/maillog or var/log/mail.log
smtpd, or other email-related services on your server.
Before implementing the audit rules, familiarize yourself with the following
fields.
pid The pid field records the pid=765 Here the above-mentione
Process ID (PID). orders some child to do th
activity. The activity don
the child process is menti
in the pid. PID is the sam
threat id.
uid 1) The uid records the real type=PATH msg=audit(12/22/2010 We need to track a user,
gid user ID of the user who 11:36:37.357:23) : item=3 whether it’s a real person
euid started the analyzed name=/etc/group~ system the user, so that w
suid process. 1) don’t lose track. For exam
fsuid 2) The gid field records type=SYSCALL by using “sudo” or “su” t
egid the group ID of the user msg=audit(12/22/2010 user will change their
sgid who started the analyzed 11:36:37.357:23) : arch=i386 previlege. In this situation
fsgid process. syscall=rename need one more sub-uid to
3) The euid field records success=yes exit=0 a0=9164890 the activity. This is
the effective user ID of a1=91cf6f8 a2=9164890 a3=91cf6f8 accomplished by assignin
the user who started the items=4 ppid=2026 extra UID. The AUID, w
analyzed process. pid=2168 auid=rainer uid=root different from the “norma
4) The suid field records gid=root euid=root suid=root UID of the user, and is
the set user ID of the user fsuid=root egid=root supposed to remain uncha
who started the analyzed sgid=root fsgid=root tty=pts0 ses=1 whatever the user does.
process. comm=vi exe=/usr/bin/vim.basic Here we have 3 groups of
5) The fsgid field records key=mykey events. Each group conta
the file system group ID 2) single type=SYSCALL it
of the user who started the type=SYSCALL which describes what bas
analyzed process. msg=audit(12/22/2010 system call has been exec
6) The egid field records 11:36:37.357:25) : arch=i386 and several other items
the effective group ID of syscall=open describing pertinent detai
the user who started the success=yes exit=3 a0=9164890 1) Action done on the pat
analyzed process. a1=241 a2=1a4 a3=0 items=2 name=/etc/group,
7) The sgid field records ppid=2026 pid=2168 2) they all refer to the
the set group ID of the auid=rainer uid=root gid=root executable
user who started the euid=root suid=root fsuid=root exe=/usr/bin/vim.basic, w
analyzed process. egid=root is the program used by th
8) The fsgid field records sgid=root fsgid=root tty=pts0 ses=1 person editing that file.
the file system group ID comm=vi exe=/usr/bin/vim.basic 3) they all point out that t
user editing the file was
uid=root, and had logged
auid=rainer.
key=mykey
4) they describe a sequen
3)
three events happening to
type=SYSCALL
edited path name=/etc/gro
msg=audit(12/22/2010
ordered by time:
11:36:37.393:26) : arch=i386
—– at 11:36:37.357:23, t
syscall=chmod
path was renamed
success=yes exit=0 a0=9164890
of the user who started the (syscall=rename) to
a1=81a4 a2=1 a3=0 items=1
analyzed process. name=/etc/group~
ppid=2026 pid=2168
—– at 11:36:37.357:25, i
auid=rainer uid=root gid=root
opened (syscall=open),
euid=root suid=root fsuid=root
presumably to write the n
egid=root
version, and finally
sgid=root fsgid=root tty=pts0 ses=1
—– at 11:36:37.393:26, t
comm=vi exe=/usr/bin/vim.basic
permissions were change
key=mykey
(syscall=chmod), most lik
reset them to the previous
value.
mode The mode field records mode=0100755 Here, the first 4 octets rep
the file or directory the fie type & the last 3 o
permissions, encoded in represent the permission
numerical notation. file set by the user.
Permission numbers are:
0=—
1 = –x
2 = -w-
3 = -wx
4 = r-
5 = r-x
6 = rw-
7 = rwx
So, here 755 means -rwxr
Conclusion:
Linux audit logs are not as difficult as we believe. It will be even more simple
when we go through the log fields before progressing with the analysis.