自定义ssh服务的日志类型和存储位置
修改日志服务配置文件:
vim /etc/rsyslog.conf
在第73行加入:
# Save boot messages also to boot.log
73 local7.* /var/log/boot.log
74 local0.* /var/log/sshd.log
把local0类别的日志保存到 /var/log/sshd.log中。vim /etc/ssh/sshd_config #修改如下内容:
将32 SyslogFacility AUTHPRIV改为32 SyslogFacility local0。systemctl restart rsyslogsystemctl restart sshdcat /var/log/sshd.log
[root@testhost ~]# cat /var/log/sshd.log
Jul 23 13:11:02 testhost sshd[26028]: Server listening on 0.0.0.0 port 22.
上面显示的日志对应的信息:时间 主机名 服务名 PID 相关的信息。
最后更新于