到目前为止,我一直试图让 rsyslog 通过 TLS 传输,但没有成功。
我的配置似乎有问题,但我无法确定它。
这是我的服务器配置文件:
# rsyslog v5 configuration file
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
#### MODULES ####
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
$ModLoad immark # provides --MARK-- message capability
$ModLoad imgssapi # provides GSSAPI syslog reception
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 10514
$InputTCPServerStreamDriverMode 1 # run driver in TLS-only mode
$InputTCPServerStreamDriverAuthMode anon # client is NOT authenticated
# make gtls driver the default
$DefaultNetstreamDriver gtls
# certificate files
$DefaultNetstreamDriverCAFile /etc/pki/tls/private/ca-cert.pem
$DefaultNetstreamDriverCertFile /etc/pki/tls/private/rslserver-cert.pem
$DefaultNetstreamDriverKeyFile /etc/pki/tls/private/rslserver-key.pem
# specify senders you permit to access
$AllowedSender TCP, 127.0.0.1, 10.111.1.0/24, *.evoltek.test.com
#add: define logfiles
## /var/log/secure
$template Auth_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.secure"
## /var/log/messages
$template Msg_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.messages"
## /var/log/maillog
$template Mail_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.maillog"
## /var/log/cron
$template Cron_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.cron"
## /var/log/spooler
$template Spool_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.spooler"
## /var/log/boot.log
$template Boot_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.boot.log"
## emergency messages "*.emerg"
$template Emerg_log,"/var/log/secure.d/%fromhost%/%$year%-%$month%.emerg"
#### GLOBAL DIRECTIVES ####
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf
#### RULES ####
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none -?Msg_log
# The authpriv file has restricted access.
authpriv.* -?Auth_log
# Log all the mail messages in one place.
mail.* -?Mail_log
# Log cron stuff
cron.* -?Cron_log
# Everybody gets emergency messages
*.emerg -?Emerg_log
# Save news errors of level crit and higher in a special file.
uucp,news.crit -?Spool_log
# Save boot messages also to boot.log
local7.* -?Boot_log
这是我的客户端配置文件:
# rsyslog v5 configuration file
# certificate files
$DefaultNetstreamDriverCAFile /etc/pki/tls/private/ca-cert.pem
$DefaultNetstreamDriverCertFile /etc/pki/tls/private/rslclient-cert.pem
$DefaultNetstreamDriverKeyFile /etc/pki/tls/private/rslclient-key.pem
$ModLoad imuxsock.so
$ModLoad imklog.so
$ModLoad imtcp
$DefaultNetstreamDriver gtls
$ActionSendStreamDriverAuthMode anon
$ActionSendStreamDriverMode 1
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
*.* @@10.111.1.151:10514
我已经按照本指南创建了证书:http: //kb.kristianreese.com/index.php ?View=entry&EntryID=148
我的测试环境没有 FQDN,因此我将 DN 字段和 FQDN 字段留空,并填写了 IP 字段。
带有 Centos 6.9 的 Rsyslog 5.8 对我有用
这是一个视频教程: https ://youtu.be/eb9GlhD8XnY
在 CA(证书颁发机构)上创建证书
安装 gnutls-utils
生成 CA 私钥(保护此密钥!)
生成 CA 公钥
在 CA(证书颁发机构)上创建 SERVERS 私钥
为 SERVER 创建证书请求
签署 SERVER 密钥并允许密钥对被其他服务器信任
在 CA(证书颁发机构)上创建 CLIENT 私钥
为 CLIENT 创建证书请求
签署 CLIENT 密钥并允许密钥对被其他服务器信任
删除请求键
Scp SERVER private/key 和 CA.pem 到 SERVER.EXAMPLE.COM 使用 scp 或 USB 加密复制证书
Scp CLIENT private/key 和 CA.pem 到 CLIENT.EXAMPLE.COM
在 SERVER 和 CLIENT 上安装 gtls 驱动程序
配置服务器
在防火墙上打开端口 6514
重新启动 rsyslog 守护进程
配置客户端
重新启动 rsyslog 守护进程
要在 SERVER 上进行测试,请运行 tcpdump 并从客户端发送日志
在 CentOS/RedHat 中,您还可以在 SElinux 中启用 SSL rsyslog 端口。类似的东西
semanage port -a -t syslogd_port_t -p tcp 10514
应该可以解决问题。您可以使用以下命令检查您当前的系统日志端口
sudo semanage port -l| grep syslog
您也可以尝试在调试模式下运行 rsyslog,看看发生了什么:停止 rsyslog 守护进程,然后
export RSYSLOG_DEBUGLOG="/path/to/debuglog"
export RSYSLOG_DEBUG="Debug"
现在启动 rsyslog:
rsyslogd -dn
要检查使用的语法是否有效,请使用:
rsyslogd -N 1
我找不到 rsyslog 5.8 的工作配置(来自 CentOS 存储库)。
我已经安装了官方的 rsyslog 存储库,并且使用此配置在几分钟内启动并运行了 rsyslog 7.6.0。