Hi,
There are many things need to be define properly first:
"interactive logons"
on windows, where Logon Type = 2 this means a real physical login with an attached keyboard.
on Linux even SSH is using the "interactive logon" phrase, but it means password authentication instead. While the logon is really a remote logon.
"service account"
On windows this is a thing.
On Linux, there is no such thing as "service account"
Once you defined what you are really looking for, on Linux you need the
Audit Logs - which is equivalent to the Microsoft Security Event Logs.
Here is one sample event aboot an SSH login:
<182>1 2023-01-18T15:00:45.863150+00:00 centos-8 audispd 25516 - - type=USER_LOGIN msg=audit(1674054045.862:4002): pid=85816 uid=0 auid=0 ses=28 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=login id=0 exe="/usr/sbin/sshd" hostname=? addr=10.172.16.2 terminal=/dev/pts/0 res=success' UID="root" AUID="root" ID="root"
Where the important custom properties would be:
- type=USER_LOGIN
- terminal=/dev/pts/0
- ID="root"
- res=success
From this the
terminal can tell you if it is a real "
logon at keyboard and screen of system" (Logon Type = 2 on windows) or a remote session.
This article may help decide by terminal names:
https://www.golinuxcloud.com/difference-between-pty-vs-tty-vs-pts-linux/
https://unix.stackexchange.com/questions/21280/difference-between-pts-and-tty
Using these information, you can create a rule triggering for what you really need...
You can read more about User Login auditing on Linux:
https://github.com/linux-audit/audit-documentation/wiki/SPEC-User-Login-Lifecycle-Events------------------------------
Laszlo Zrubecz
------------------------------