如何在rhel 6中将ssh日志位置从/var/log/secure更改为自定义位置?

Mua*_*sir 5 ssh rsyslog

默认情况下,在 RHEL 6 中,SSH 服务器日志发送到/var/log/secure. 我想将此位置更改为自定义位置。有可能这样做吗?

我试过修改rsyslog.conf文件,但它不起作用。

beg*_*ner 5

选择一个未使用的本地设施。例如,local3 不用于系统中的任何日志记录。所以首先编辑/etc/sshd_config配置文件。

 #SyslogFacility AUTH
 SyslogFacility local3
Run Code Online (Sandbox Code Playgroud)

现在配置 rsyslog 将 local3 日志记录到您需要的文件中。将以下内容添加到您的/etc/rsyslog.conf.

#Logging sshd to another file. Using local3 facility.
local3.* /SOME/PATH/YOU/WANT/YOUR/SSHD/LOGS/TO-BE.log
Run Code Online (Sandbox Code Playgroud)

当然,其中/SOME/PATH/YOU/WANT/YOUR/SSHD/LOGS/TO-BE.log 应该替换为您想要重定向 sshd 日志的文件的位置,明智地我希望可以是/var/log/sshd.log.

然后像往常一样,重新启动服务:

   service rsyslogd restart 
Run Code Online (Sandbox Code Playgroud)