Introduction
I mostly work with Windows systems but I do also like to work with Linux systems too since there are benefits with it. As an example it consumes less resources, terminal is friendly, and its more reliable than Windows.
One thing that I always have been interested in knowing more about is the right-way of logging logs in Linux. This is where I stumbled upon RSYSLOG and decided to learn as much as possible about it.
What is RSYSLOG?
RSYSLOG is a application that is is efficent at collecting, transforming, and routing event data. Its widely used by organizations to collect event data from different operating systems and applications.
flowchart RL s01["Server (Listener)"] s02["Server (Forwarder)"] s03["Server (Forwarder)"] s04["Server (Forwarder)"] s02 --> s01 s03 --> s01 s04 --> s01
As an example we can have a primary server which is a receiver and then have all our servers sending authentication, application, and kernel related data to primary server.
Installing RSYSLOG
sudo apt-get update -y
sudo apt-get install rsyslog -ySetting Up Receiver
The Receiver is responsible for receiving and processing all the data which arrives from the different servers. This server is our guardian responsible for ensuring only data which we are interested in are going through.
As an example I’ll be configuring our Primary Server to only process events that are related to events such as ssh and su.
module(load="imtcp")
module(load="omprog")
input(type="imtcp" port="514" ruleset="remote")
# Predefined paths
template(name="AuthLoggingPath" type="string" string="/var/log/remote-auth.log")
ruleset(name="remote") {
if $programname startswith "sshd" or $programname startswith "unix_chkpwd" then {
action(type="omfile" name="store_remote_auth" dynaFile="AuthLoggingPath")
}
}We are creating the file inside of /etc/rsyslog.d/*.conf since the global config /etc/rsyslog.conf will automatically include our 10-receiver.conf configuration for us.
The imtcp is a module used for creating the listener while omprog is a module used for writing event data into a file. And each time a event comes from services such as ssh and su these are logged inside of /var/log/remote-auth.log file.
Setting Up Forwarder
The Forwarder is the servers which will be forwarding the events to the Receiver server. I’ll be configuring the configuration file to only send data which is related to ssh and su.
if $programname startswith "sshd" or $programname startswith "unix_chkpwd" then {
action(type="omfwd"
name="fwd_failed_logins"
target="192.168.107.170"
port="514"
protocol="tcp"
template="RSYSLOG_SyslogProtocol23Format"
action.resumeRetryCount="-1"
action.resumeIntervals="10"
queue.type="LinkedList"
queue.filename="fwd_auth"
queue.maxDiskSpace="1g"
queue.saveOnShutdown="on")
}Each time an event occurs on ssh and su these are forwarded to the Receiver Server which at port 514. There is also ways for us to implement things better using properties such as $msg and $syslogseverity-text.
Troubleshooting
Results
We can now try logging into the Forwarder server with wrong credentials using ssh and su; these should be logged inside of our Receiver server.
2026-11-29T13:50:35.150401+00:00 ubuntu-02 sshd-session[4644] Failed password for husenjan from 192.168.107.1 port 55922 ssh2
2026-11-29T13:51:33.682245+00:00 ubuntu-02 sshd-session[4644] Failed password for husenjan from 192.168.107.1 port 55922 ssh2
2026-11-29T13:51:34.559089+00:00 ubuntu-02 sshd-session[4644] PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.107.1 user=husenjanWith the event data we received from these different data sources, we could perform operations such as executing a script which sends us notifications or blocks the IPv4 address.
Conclusion
RSYSLOG is a great way of collecting, transforming, and routing event data. We have only touched the surface but there are many things we can do such as implementing logrotate to compress and preserve log data. Its also possible to implement a notification system. I’ll be diving deeper into RSYSLOG in the coming weeks.