当前位置:   article > 正文

Wazuh部署之部署_wazuh已与elastic stack

wazuh已与elastic stack

Wazuh由部署到受监视系统的端点安全代理和管理服务器组成,管理服务器收集和分析代理收集的数据。此外,Wazuh已与Elastic Stack完全集成,提供了搜索引擎和数据可视化工具,使用户可以浏览其安全警报。

Wazuh提供的功能包括日志数据分析,入侵和恶意软件检测,文件完整性监视,配置评估,漏洞检测以及对法规遵从性的支持。

本次将部署一套分布式Wazuh方案:

  1. wazuh-master启用全功能组件;
  2. ElasticStack将使用官方基本授权,不启用X-pack和加密连接;
  3. Linux版本Agent将安装到Kibana主机和ElasticSearch主机上,不再额外安装示例主机;
  4. 各个功能组件采用单节点部署;
  5. Wazuh使用4.1.5版本,搭配官方指定7.11.2ElasticStack版本。
  6. 部署方案
  7. 部署拓扑

  8. 网络地址

    系统角色版本网络地址
    ElasticSearch7.11.2192.168.248.146
    Kibana7.11.2192.168.248.145
    WazuhMaster4.1.5192.168.248.150
    WazuhAgent4.1.5192.168.248.1
  9. 部署实施

    1. # 安装前置软件
    2. yum install -y zip unzip curl
    3. # 导入秘钥
    4. rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
    5. # 增加官方源
    6. cat > /etc/yum.repos.d/elastic.repo << EOF
    7. [elasticsearch-7.x]
    8. name=Elasticsearch repository for 7.x packages
    9. baseurl=https://artifacts.elastic.co/packages/7.x/yum
    10. gpgcheck=1
    11. gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
    12. enabled=1
    13. autorefresh=1
    14. type=rpm-md
    15. EOF
    16. # 安装软件
    17. yum makecache
    18. yum upgrade -y
    19. yum install -y elasticsearch-7.11.2
    20. # 导入配置文件
    21. mv /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml-bak
    22. touch /etc/elasticsearch/elasticsearch.yml
    23. cat > /etc/elasticsearch/elasticsearch.yml << EOF
    24. cluster.name: elastic
    25. node.name: elasticnode1
    26. network.host: 192.168.248.146
    27. cluster.initial_master_nodes: ["elasticnode1"]
    28. path.data: /var/lib/elasticsearch
    29. path.logs: /var/log/elasticsearch
    30. EOF
    31. # 开通防火墙
    32. firewall-cmd --permanent --add-service=elasticsearch
    33. firewall-cmd --reload
    34. # 启动服务
    35. systemctl daemon-reload
    36. systemctl enable elasticsearch
    37. systemctl start elasticsearch
    38. # 校验服务
    39. # 使用其他主机访问es环境
    40. curl -XGET http://192.168.248.146:9200
    41. {
    42. "name" : "elasticnode1",
    43. "cluster_name" : "elastic",
    44. "cluster_uuid" : "ahjxhVEHREKNmBAfjcuyNw",
    45. "version" : {
    46. "number" : "7.11.2",
    47. "build_flavor" : "default",
    48. "build_type" : "rpm",
    49. "build_hash" : "3e5a16cfec50876d20ea77b075070932c6464c7d",
    50. "build_date" : "2021-03-06T05:54:38.141101Z",
    51. "build_snapshot" : false,
    52. "lucene_version" : "8.7.0",
    53. "minimum_wire_compatibility_version" : "6.8.0",
    54. "minimum_index_compatibility_version" : "6.0.0-beta1"
    55. },
    56. "tagline" : "You Know, for Search"
    57. }
    58. # 禁用软件源,避免非控升级组件
    59. sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/elastic.repo

    10.Kibana的安装

    1. # 安装前置软件
    2. yum install -y zip unzip curl
    3. # 导入源秘钥
    4. rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
    5. # 增加官方源
    6. cat > /etc/yum.repos.d/elastic.repo << EOF
    7. [elasticsearch-7.x]
    8. name=Elasticsearch repository for 7.x packages
    9. baseurl=https://artifacts.elastic.co/packages/7.x/yum
    10. gpgcheck=1
    11. gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
    12. enabled=1
    13. autorefresh=1
    14. type=rpm-md
    15. EOF
    16. # 安装软件
    17. yum makecache
    18. yum upgrade -y
    19. yum install -y kibana-7.11.2
    20. # 修改配置文件
    21. cp /etc/kibana/kibana.yml /etc/kibana/kibana.yml-bak
    22. cat >> /etc/kibana/kibana.yml << EOF
    23. server.port: 5601
    24. server.host: "localhost"
    25. server.name: "kibana"
    26. i18n.locale: "en"
    27. elasticsearch.hosts: ["http://192.168.248.146:9200"]
    28. kibana.index: ".kibana"
    29. kibana.defaultAppId: "home"
    30. EOF
    31. # 创建数据目录
    32. mkdir /usr/share/kibana/data
    33. chown -R kibana:kibana /usr/share/kibana
    34. # 离线安装插件
    35. wget https://packages.wazuh.com/4.x/ui/kibana/wazuh_kibana-4.1.5_7.11.2-1.zip
    36. cp ./wazuh_kibana-4.1.5_7.11.2-1.zip /tmp
    37. cd /usr/share/kibana
    38. sudo -u kibana /usr/share/kibana/bin/kibana-plugin install file:///tmp/wazuh_kibana-4.1.5_7.11.2-1.zip
    39. # 配置服务
    40. systemctl daemon-reload
    41. systemctl enable kibana
    42. systemctl start kibana
    43. # 禁用软件源,避免非控升级组件
    44. sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/elastic.repo
    45. # 配置反向代理
    46. yum install -y nginx
    47. systemctl enable --now nginx
    48. vim /etc/ngix/nginx.conf.default
    49. # 在server{}中添加配置项
    50. ​```
    51. proxy_redirect off;
    52. proxy_set_header X-Real-IP $remote_addr;
    53. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    54. proxy_set_header Host $http_host;
    55. location / {
    56. proxy_pass http://localhost:5601/;
    57. }
    58. ​```
    59. nginx -s reload
    60. # 登录kibana之后选择wazuh插件
    61. # 返回控制台修改插件配置文件
    62. sed -i ‘:s/localhost/192.168.248.150/g’ /usr/share/kibana/data/wazuh/config/wazuh.yml

    11.WazuhMaster的安装

    1. # 安装前置软件
    2. yum install -y zip unzip curl
    3. # 导入秘钥
    4. rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH
    5. rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
    6. # 配置官方软件源
    7. cat > /etc/yum.repos.d/wazuh.repo << EOF
    8. [wazuh]
    9. gpgcheck=1
    10. gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH
    11. enabled=1
    12. name=EL-$releasever - Wazuh
    13. baseurl=https://packages.wazuh.com/4.x/yum/
    14. protect=1
    15. EOF
    16. cat > /etc/yum.repos.d/elastic.repo << EOF
    17. [elasticsearch-7.x]
    18. name=Elasticsearch repository for 7.x packages
    19. baseurl=https://artifacts.elastic.co/packages/7.x/yum
    20. gpgcheck=1
    21. gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
    22. enabled=1
    23. autorefresh=1
    24. type=rpm-md
    25. EOF
    26. # 安装软件
    27. yum makecache
    28. yum upgrade -y
    29. yum install -y wazuh-manager
    30. yum install filebeat-7.11.2
    31. # 配置Filebeat
    32. mv /etc/filebeat/filebeat.yml /etc/filebeat/filebeat.yml-bak
    33. touch /etc/filebeat/filebeat.yml
    34. cat > /etc/filebeat/filebeat.yml<<EOF
    35. filebeat.modules:
    36. - module: wazuh
    37. alerts:
    38. enabled: true
    39. archives:
    40. enabled: false
    41. setup.template.json.enabled: true
    42. setup.template.json.path: '/etc/filebeat/wazuh-template.json'
    43. setup.template.json.name: 'wazuh'
    44. setup.template.overwrite: true
    45. setup.ilm.enabled: false
    46. output.elasticsearch.hosts: ['http://192.168.248.146:9200']
    47. EOF
    48. # 导入filebeat的wazuh日志模板
    49. curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/4.1/extensions/elasticsearch/7.x/wazuh-template.json
    50. chmod go+r /etc/filebeat/wazuh-template.json
    51. # 导入filebeat的wazuh日志模型
    52. curl -s https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.1.tar.gz | tar -xvz -C /usr/share/filebeat/module
    53. # 配置防火墙规则
    54. firewall-cmd --permanent --add-port={1514/tcp,1515/tcp,55000/tcp}
    55. firewall-cmd --reload
    56. # 禁用软件源,避免非控升级组件
    57. sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/elastic.repo
    58. sed -i "s/^enabled=1/enabled=0/" /etc/yum.repos.d/wazuh.repo
    59. # 启动服务
    60. systemctl daemon-reload
    61. systemctl enable --now wazuh-manager
    62. systemctl enable --now filebeat
    63. # 验证Filebeat
    64. filebeat test output
    65. ···
    66. elasticsearch: http://192.168.248.146:9200...
    67. parse url... OK
    68. connection...
    69. parse host... OK
    70. dns lookup... OK
    71. addresses: 192.168.248.146
    72. dial up... OK
    73. TLS... WARN secure connection disabled
    74. talk to server... OK
    75. version: 7.11.2
    76. ···
    77. # 刷新kibana

    12.WazuhAgent的安装(Linux)

    1. # 在es节点和kibana节点上安装
    2. sudo WAZUH_MANAGER='192.168.248.150' WAZUH_AGENT_GROUP='default' yum install -y https://packages.wazuh.com/4.x/yum/wazuh-agent-4.1.5-1.x86_64.rpm
    3. # 启动服务
    4. sudo systemctl daemon-reload
    5. sudo systemctl enable wazuh-agent
    6. sudo systemctl start wazuh-agent

    13.WazuhAgent的安装(Windows)

    1. # 使用管理员权限打开powershell控制台
    2. Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-4.1.5-1.msi -OutFile wazuh-agent.msi; ./wazuh-agent.msi /q WAZUH_MANAGER='192.168.248.150' WAZUH_REGISTRATION_SERVER='192.168.248.150' WAZUH_AGENT_GROUP='default'

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号