在Debian上安全設置Filebeat涉及多個方面,包括安裝、配置、權限設置和防火墻配置。以下是詳細的步驟和建議:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
sudo apt-get update && sudo apt-get install filebeat
/etc/filebeat/filebeat.yml 文件,配置Filebeat的輸入和輸出。例如:filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/*.log
output.elasticsearch:
hosts: ["localhost:9200"]
sudo useradd -r -s /sbin/nologin filebeat
sudo chown -R filebeat:filebeat /etc/filebeat
sudo chmod -R 750 /etc/filebeat
output.elasticsearch.ssl.enabled: true
output.elasticsearch.ssl.certificate: /path/to/certificate.pem
output.elasticsearch.ssl.key: /path/to/key.pem
sudo iptables -A INPUT -p tcp --dport 5044 -j ACCEPT # Logstash
sudo iptables -A INPUT -p tcp --dport 9200 -j ACCEPT # Elasticsearch
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT # SSH
sudo iptables-save /etc/iptables/rules.v4
sudo systemctl enable iptables
sudo systemctl start iptables
logging.level: info
logging.to_files: true
logging.files:
path: /var/log/filebeat/filebeat.log
name: filebeat
keepfiles: 7
permissions: 0644
sudo apt-get update && sudo apt-get upgrade filebeat
通過以上步驟,你可以在Debian上安全地設置和運行Filebeat,確保日志數據的收集和傳輸過程安全可靠。