在 Debian 上,Filebeat 本身不负责“数据加密存储”,而是通过在**传输层加密(TLS)和输出目标加密(如 Elasticsearch / Logstash HTTPS)**来实现“加密”。常见做法如下:
sudo apt update
sudo apt install filebeat
如果你有 CA:
ca.crt(CA 证书)filebeat.crt(客户端证书,可选)filebeat.key(客户端私钥,可选)示例目录:
/etc/filebeat/certs/ca.crt
/etc/filebeat/certs/filebeat.crt
/etc/filebeat/certs/filebeat.key
编辑 /etc/filebeat/filebeat.yml:
output.elasticsearch:
hosts: ["https://es.example.com:9200"]
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
certificate: "/etc/filebeat/certs/filebeat.crt"
key: "/etc/filebeat/certs/filebeat.key"
output.logstash:
hosts: ["logstash.example.com:5044"]
ssl:
enabled: true
certificate_authorities: ["/etc/filebeat/certs/ca.crt"]
sudo chown -R root:root /etc/filebeat/certs
sudo chmod 600 /etc/filebeat/certs/filebeat.key
sudo filebeat test output
sudo systemctl restart filebeat
sudo systemctl enable filebeat
在 Logstash 端也要配置:
input {
beats {
port => 5044
ssl => true
ssl_certificate => "/etc/logstash/certs/logstash.crt"
ssl_key => "/etc/logstash/certs/logstash.key"
ssl_certificate_authorities => ["/etc/logstash/certs/ca.crt"]
ssl_verify_mode => "force_peer"
}
}
如果你指的是Filebeat 收集的日志在磁盘上加密:
sudo apt install cryptsetup
如果你使用 Elastic Stack:
elasticsearch-certutil示例:
output.elasticsearch:
hosts: ["https://es.example.com:9200"]
username: "filebeat_writer"
password: "${FILEBEAT_PASSWORD}"
| 需求 | 解决方案 |
|---|---|
| 传输加密 | TLS / HTTPS |
| 双向认证 | mTLS |
| 日志磁盘加密 | LUKS |
| 权限保护 | 600 私钥 |
如果你是 具体场景(如:Filebeat → Kafka、Filebeat → 自建 ES、容器环境),可以告诉我,我给你对应配置。