Debian Filebeat如何进行数据加密
导读:Debian上Filebeat数据加密实操指南 一 前置准备 安装Filebeat(Debian):建议使用官方或Elastic APT仓库,导入GPG并添加源后安装,主配置文件位于**/etc/filebeat/filebeat.yml...
Debian上Filebeat数据加密实操指南
一 前置准备
- 安装Filebeat(Debian):建议使用官方或Elastic APT仓库,导入GPG并添加源后安装,主配置文件位于**/etc/filebeat/filebeat.yml**。完成后确认服务可用。
- 证书准备:生成或获取CA证书、Filebeat的客户端证书与私钥,并按统一目录存放,例如**/etc/filebeat/pki/tls/{ certs,private} **。生产环境建议使用受信任CA签发的证书。
二 生成证书示例
- 创建目录
- mkdir -p /etc/filebeat/pki/tls/{ certs,private}
- 生成CA证书(示例有效期3650天)
- openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/filebeat/pki/tls/private/ca.key -out /etc/filebeat/pki/tls/certs/ca.crt -subj “/CN=Elastic CA”
- 生成Filebeat客户端证书与私钥(示例有效期365天)
- openssl req -newkey rsa:2048 -nodes -keyout /etc/filebeat/pki/tls/private/filebeat.key -out /etc/filebeat/pki/tls/certs/filebeat.csr -subj “/CN=filebeat.example.com”
- openssl x509 -req -in /etc/filebeat/pki/tls/certs/filebeat.csr -CA /etc/filebeat/pki/tls/certs/ca.crt -CAkey /etc/filebeat/pki/tls/private/ca.key -CAcreateserial -out /etc/filebeat/pki/tls/certs/filebeat.crt -days 365
证书路径与文件名可按实际环境调整,但需与Filebeat配置保持一致。
三 配置Filebeat启用TLS加密
- 输出到Elasticsearch(HTTPS)
- 在**/etc/filebeat/filebeat.yml**中启用TLS并指定证书路径与服务器地址:
- output.elasticsearch:
- hosts: [“https://elasticsearch.example.com:9200”]
- ssl.enabled: true
- ssl.verification_mode: certificate
- ssl.certificate_authorities: [“/etc/filebeat/pki/tls/certs/ca.crt”]
- ssl.certificate: “/etc/filebeat/pki/tls/certs/filebeat.crt”
- ssl.key: “/etc/filebeat/pki/tls/private/filebeat.key”
- output.elasticsearch:
- 在**/etc/filebeat/filebeat.yml**中启用TLS并指定证书路径与服务器地址:
- 输出到Logstash(TLS)
- 在对应的Logstash输出段添加与上述一致的**ssl.**参数,确保证书路径与CA一致。
- 说明
- 若Elasticsearch启用X-Pack安全,可同时配置用户名/密码或API Key进行身份认证,与TLS叠加使用更安全。
四 服务端Elasticsearch必要配置
- 启用安全功能与HTTP层TLS(示例)
- xpack.security.enabled: true
- xpack.security.http.ssl.enabled: true
- xpack.security.http.ssl.certificate: “/etc/elasticsearch/certs/http.pem”
- xpack.security.http.ssl.key: “/etc/elasticsearch/certs/http-key.pem”
- xpack.security.http.ssl.certificate_authorities: [“/etc/elasticsearch/certs/ca.pem”]
- 集群内部传输加密(如部署多节点)
- xpack.security.transport.ssl.enabled: true
- xpack.security.transport.ssl.verification_mode: certificate
- xpack.security.transport.ssl.keystore.path: “elastic-certificates.p12”
- xpack.security.transport.ssl.truststore.path: “elastic-certificates.p12”
- 完成后重启Elasticsearch使配置生效。
五 生效验证与加固建议
-
生效与验证
- 重启Filebeat:systemctl restart filebeat
- 查看状态与日志:systemctl status filebeat;tail -f /var/log/filebeat/filebeat
- 确认日志中无TLS握手或证书验证错误,且事件正常发送。
-
加固建议
- 文件与目录权限:chmod 600 /etc/filebeat/filebeat.yml;chown -R filebeat:filebeat /etc/filebeat /var/log/filebeat
- 以非特权用户运行:在systemd服务单元设置User=filebeat,避免使用root
- 网络访问控制:使用UFW/iptables仅允许必要来源IP访问9200/5044等端口
- 证书与组件维护:提前规划证书有效期与轮换;保持Filebeat与Elasticsearch及时更新并定期审计配置
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: Debian Filebeat如何进行数据加密
本文地址: https://pptw.com/jishu/761158.html
