在Ubuntu 20.04上安装OSSEC HIDS代理
本教程将指导您如何从源tarball在Ubuntu 20.04系统上安装OSSEC HIDS代理。
OSSEC 是基于开源主机的入侵检测系统,它执行日志分析,完整性检查,Windows注册表监视,rootkit检测,实时警报和主动响应。它可以跨多个平台运行,包括Linux,OpenBSD,FreeBSD,Mac OS X,Solaris和Windows等。
在Ubuntu 20.04上安装OSSEC HIDS代理
运行系统更新
首先,请确保您的系统软件包缓存是最新的。
apt update
安装必需的依赖项
从源代码上成功在Ubuntu 20.04上成功构建和安装OSSEC HIDS代理程序,需要在系统上安装大量依赖项。运行以下命令以安装这些依赖项。
apt install gcc make libevent-dev zlib1g-dev libssl-dev libpcre2-dev wget tar -y
下载最新的OSSEC源代码
截至撰写本文时,OSSEC 3.6是最新的稳定发行版。检查 发布页面 以获取最新版本。
wget https://github.com/ossec/ossec-hids/archive/3.6.0.tar.gz -P /tmp
提取OSSEC源代码
OSSEC源代码下载完成后,请按以下步骤将其解压缩;
cd /tmp
tar xzf 3.6.0.tar.gz
在Ubuntu 20.04上安装OSSEC HIDS代理
要安装OSSEC代理,请导航至源代码目录并运行安装脚本。
cd ossec-hids-3.6.0/
执行安装组;
./install.sh
选择您的安装语言。在这种情况下,我们选择默认的安装语言,英语。
按ENTER键选择默认安装选项,或从列表中选择您的语言。
(en/br/cn/de/el/es/fr/hu/it/jp/nl/pl/ru/sr/tr) [en]: ENTER
再次,按ENTER继续。
-- Press ENTER to continue or Ctrl-C to abort. --
指定安装类型。就我们而言,我们正在安装ossec-hids agent
,因此选择代理商。
1- What kind of installation do you want (server, agent, local, hybrid or help)? agent - Agent(client) installation chosen.
选择安装路径。我们采用默认值, /var/ossec
。
2- Setting up the installation environment. - Choose where to install the OSSEC HIDS [/var/ossec]: ENTER - Installation will be made at /var/ossec .
输入OSSEC-HIDs服务器IP地址或主机名。相应地替换此处使用的IP。
3- Configuring the OSSEC HIDS. 3.1- What's the IP Address or hostname of the OSSEC HIDS server?: 192.168.56.11 - Adding Server IP 192.168.56.11
启用系统完整性检查
3.2- Do you want to run the integrity check daemon? (y/n) [y]: y - Running syscheck (integrity check daemon).
启用rootkit检测引擎。
3.3- Do you want to run the rootkit detection engine? (y/n) [y]: y - Running rootcheck (rootkit detection).
禁用主动响应。否则,如果您了解所需警报的类型和数量,则可以启用它。
3.4 - Do you want to enable active response? (y/n) [y]: n - Active response disabled.
然后,代理安装程序将显示默认情况下读取的日志文件。您以后可以添加更多 ossec.conf
文件。
3.5- Setting the configuration to analyze the following logs: -- /var/log/messages -- /var/log/secure -- /var/log/maillog ...
定义默认选项后,请按ENTER继续在Ubuntu 20.04上安装OSSEC代理。
安装代理后,您将看到类似于以下的输出:
- System is Debian (Ubuntu or derivative).
- Init script modified to start OSSEC HIDS during boot.
- Configuration finished properly.
- To start OSSEC HIDS:
/var/ossec/bin/ossec-control start
- To stop OSSEC HIDS:
/var/ossec/bin/ossec-control stop
- The configuration can be viewed or modified at /var/ossec/etc/ossec.conf
Thanks for using the OSSEC HIDS.
If you have any question, suggestion or if you find any bug,
contact us at https://github.com/ossec/ossec-hids or using
our public maillist at
https://groups.google.com/forum/#!forum/ossec-list
More information can be found at http://www.ossec.net
--- Press ENTER to finish (maybe more information below). ---
按ENTER键关闭安装程序。
将OSSEC代理连接到OSSEC服务器
供代理与服务器通信;
- 您可能需要先将其添加到HIDS服务器,在本例中,我们使用的是AlienVault OSSIM。
- 之后,从服务器中提取代理身份验证密钥。
提取密钥后,通过运行以下命令在代理上导入密钥;
/var/ossec/bin/manage_agents
输入选项 一世, 粘贴钥匙 和 确认添加密钥。然后输入 问 和 按Enter 退出。
**************************************** * OSSEC HIDS v3.6.0 Agent manager. * * The following options are available: * **************************************** (I)mport key from the server (I). (Q)uit. Choose your action: I or Q: I * Provide the Key generated by the server. * The best approach is to cut and paste it. *** OBS: Do not include spaces or new lines. Paste it here (or 'q' to quit): NSttstGSTsgspsgsjshsYmV5a2ktb3Blbnzk999383nndZwbiAxMC43LjMuNTggMWQyNzBjZTZlNzI2OGI2MWUzOWQ4NTg4YjgwM2ZjNDhhZWY2OTQxZTU2OWE2M2U3MjQ1N2Y1w== Agent information: ID:10 Name:koromicha IP Address:192.168.43.17 Confirm adding it?(y/n): y 2020/06/22 20:16:03 manage_agents: ERROR: Cannot unlink /queue/rids/sender: No such file or directory Added. ** Press ENTER to return to the main menu. **************************************** * OSSEC HIDS v3.6.0 Agent manager. * * The following options are available: * **************************************** (I)mport key from the server (I). (Q)uit. Choose your action: I or Q: q ** You must restart OSSEC for your changes to take effect. manage_agents: Exiting. manage_agents: Exiting.
运行OSSEC代理
安装完成后,安装程序将显示如何运行OSSEC代理。
启动代理;
/var/ossec/bin/ossec-control start
要么
systemctl start ossec
停止代理;
/var/ossec/bin/ossec-control stop
要么
systemctl stop ossec
其他单元服务控制命令;
/var/ossec/bin/ossec-control {start|stop|reload|restart|status}
检查状态;
/var/ossec/bin/ossec-control status
ossec-logcollector is running... ossec-syscheckd is running... ossec-agentd is running... ossec-execd not running...
检查日志以查看代理是否已连接到服务器;
tail -f /var/ossec/logs/ossec.log
2020/06/22 20:20:54 ossec-agentd(4101): WARN: Waiting for server reply (not started). Tried: '192.168.56.11'. 2020/06/22 20:20:56 ossec-agentd: INFO: Trying to connect to server 192.168.56.11, port 1514. 2020/06/22 20:20:56 INFO: Connected to 192.168.56.11 at address 192.168.56.11, port 1514 2020/06/22 20:20:56 ossec-agentd: DEBUG: agt->sock: 14 ...
您已在Ubuntu 20.04上成功安装OSSEC代理并将其连接到HIDS服务器。
登录回HIDs服务器,重新启动HIDS服务器服务,并检查代理是否处于活动状态。
这使我们到了如何在Ubuntu 20.04上安装OSSEC HIDS代理的指南的结尾。
进一步阅读
。