You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-42
Original file line number
Diff line number
Diff line change
@@ -9,49 +9,71 @@ No any agents are required. Just set it up and you can distribute the configurat
9
9
10
10
# Logging field information
11
11
12
-
ID | Field | Channel
12
+
no | field | description
13
13
----- | ----- | -----
14
-
1 | time_now | current time
15
-
2 | tme_hms | current time - hours/minutes/seconds
16
-
3 | tty_number | Type and number of the current terminal session
17
-
4 | user | current login username
18
-
5 | is_root | current user is root or not
19
-
6 | shell_status | check user prompt. if root "#", not root "$"
20
-
7 | ip | IP address connecting from a remote
21
-
8 | current_path | the current working directory in the shell
22
-
9 | command | the command entered in the shell.
23
-
10 | ps | A custom field that is left in the same way as the PS status of the shell.
14
+
1 | ctime_hms | The current time in the format of HH:MM:SS.
15
+
2 | login_user | The username of the user who is currently logged in.
16
+
3 | sudo_user | The username of the user who used sudo to run the command. If sudo wasn't used, set this variable to "null".
17
+
4 | is_root | Whether the current user is the root user. If the current user is the root user, set this variable to "y". Otherwise, set it to "n".
18
+
5 | shell_status | The command prompt symbol. If the current user is the root user, set this variable to "#". Otherwise, set it to "$".
19
+
6 | remote_ip | he IP address of the remote host that the user logged in from.
20
+
7 | pwd | The current working directory.
21
+
8 | command | The command that was executed.
22
+
9 | cmd_retn_code | The return code of the command that was executed.
23
+
10 | cmd_pid | The process ID of the command that was executed.
24
+
11 | sudo_chk | Whether the command that was executed used sudo. If the command used sudo, set this variable to "y". Otherwise, set it to "n".
25
+
12 | sudo_with | Whether sudo was used to run the command. If the current user is the root user, set this variable to "y". Otherwise, set it to the value of sudo_chk.
26
+
13 | ps | The command prompt string.
27
+
28
+
# Variables in logging
29
+
30
+
no | field | description
31
+
----- | ----- | -----
32
+
1 | datetime | The date and time when the command was executed.
33
+
2 | tty | The terminal device name.
34
+
3 | bash_pid | The process ID of the current bash shell.
35
+
4 | type | The type of the log entry. "new_login" or "logged_in".
36
+
5 | username | The username of the user who executed the command.
37
+
6 | sudo_user | The username of the user who used sudo to run the command. If sudo wasn't used, this variable is set to "null".
38
+
7 | root | Whether the current user is the root user. If the current user is the root user, this variable is set to "y". Otherwise, it's set to "n".
39
+
8 | ip | The IP address of the remote host that the user logged in from.
40
+
9 | pwd | The current working directory.
41
+
10 | cmd | The command that was executed
24
42
25
43
# SET-UP
26
44
27
45
1. Create a file named "e.g) history_log.sh" under the "/etc/profile.d/" directory and add the following code to it:
.... cmd_h1st[720750]: datetime='2023-02-11 07:16:52',tty='2',user='root',root='y',ip='1*5.2**.*9.1**',pwd='/root',cmd='ll',ps='[07:16:52][root@buddy]/root~# ll'
80
-
.... cmd_h1st[720797]: datetime='2023-02-11 07:18:14',tty='2',user='root',root='y',ip='1*5.2**.*9.1**',pwd='/root',cmd='vim /etc/rsyslog.conf ',ps='[07:18:14][root@buddy]/root~# vim /etc/rsyslog.conf '
- In case multiple users log in with the same username, we can individually identify who they are.
96
107
- By default, when a user change level to root, their IP address is lost, so making it impossible to recored the user's remote connection ip, but it is fine now. IP is recorded in all cases.
0 commit comments