LoginSignup
4
4

More than 5 years have passed since last update.

CentOS7.x で OSSEC マネージャとエージェントのインストール

Posted at

マネージャ、エージェントともに CentOS 7.2 です。
インストールの方法はyumで atomicorp のリポジトリを追加しインストールします。

役割 ホスト名 IP アドレス
マネージャ manager 192.168.0.254
エージェント agent 192.168.0.128

マネージャの方で iptables とか firewalld が有効になっている場合は udp/1514 を開けておく

マネージャ、エージェントともに atomicorp リポジトリの追加

wget -q -O - http://www.atomicorp.com/installers/atomic | sh

マネージャへパッケージのインストール

manager $ sudo yum install ossec-hids ossec-hids-server

エージェントでもインストール

agent $ sudo yum install ossec-hids ossec-hids-client

インストールに時間がかかると思うけど、原因は連携のためのキーが新規インストール時には登録されていないため

マネージャを起動する

manager $ sudo /etc/init.d/ossec-hids start

マネージャでエージェントを登録する

manager $ sudo /var/ossec/bin/manage_agents


****************************************
* OSSEC HIDS v2.8.3 Agent manager.     *
* The following options are available: *
****************************************
   (A)dd an agent (A).
   (E)xtract key for an agent (E).
   (L)ist already added agents (L).
   (R)emove an agent (R).
   (Q)uit.
Choose your action: A,E,L,R or Q: A  # A を入力し Enter

- Adding a new agent (use '\q' to return to the main menu).
  Please provide the following:
   * A name for the new agent: agent   # エージェントのホスト名を入力し Enter    
   * The IP Address of the new agent: 192.168.0.128 # エージェントの IP アドレスを入力し Enter
   * An ID for the new agent[001]:    # エージェントの ID は入力せずに Enter でも大丈夫
Agent information:
   ID:001
   Name:agent
   IP Address:192.168.0.128

Confirm adding it?(y/n): y  # 間違いがなければ y を入力し Enter
Agent added.

続けてエージェントに登録するためのキーを発行する。

****************************************
* OSSEC HIDS v2.8.3 Agent manager.     *
* The following options are available: *
****************************************
   (A)dd an agent (A).
   (E)xtract key for an agent (E).
   (L)ist already added agents (L).
   (R)emove an agent (R).
   (Q)uit.
Choose your action: A,E,L,R or Q: E  # E を入力し Enter

Available agents:
   ID: 001, Name:agent, IP: 192.168.0.128
Provide the ID of the agent to extract the key (or '\q' to quit): 001 # 対象のエージェントの ID を入力し Enter

Agent key information for '001' is:
<AGENT_KEY> # 表示されたキーをこぴーしておく
** Press ENTER to return to the main menu.

 # メインメニューが表示されら Q を入力 Enter

マネージャを再起動しておく

manager $ sudo /etc/init.d/ossec-hids restart

エージェント側で設定ファイルの編集

agent $ sudo ls -la /var/ossec/etc/ossec.conf
lrwxrwxrwx  1 root  root    16 10月  4 14:42 ossec.conf -> ossec-agent.conf

agent $ sudo vi /var/ossec/etc/ossec.conf  # 実体は ossec-agent.conf

<!-- OSSEC example config -->

<ossec_config>
  <client>
    <server-ip>192.168.0.254</server-ip>   # マネージャの IP アドレスへ変更
  </client>

  <syscheck>
    <!-- Frequency that syscheck is executed -- default every 2 hours -->
    <frequency>7200</frequency>

マネージャで発行したキーをインポートする。

agent $ sudo /var/ossec/bin/manage_client


****************************************
* OSSEC HIDS v2.8.3 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):
 <AGENT_KEY>  # マネージャで発行したキーを貼り付けて Enter

Agent information:
   ID:001
   Name:agent
   IP Address:192.168.0.128

Confirm adding it?(y/n): y  # 間違いなければ y 入力して Enter
Added.

エージェントを起動する。

agent $ sudo /etc/init.d/ossec-hids start

マネージャ側で認識できているか agent_control コマンドで確認

manager $ sudo /var/ossec/bin/agent_control -i 001

OSSEC HIDS agent_control. Agent information:
   Agent ID:   001
   Agent Name: agent
   IP address: 192.168.0.128
   Status:     Active

   Operating system:    Linux agent 3.10.0-327.36.1.el7.x86_64 #1 S..
   Client version:      OSSEC HIDS v2.8.3 / 6322ee12ea9a05951f97923a8341a01a
   Last keep alive:     Tue Oct  4 15:05:19 2016

   Syscheck last started  at: Tue Oct  4 15:07:18 2016
   Rootcheck last started at: Unknown

StatusActive になっていないようであれば
マネージャ、エージェントともに

$ sudo /etc/init.d/ossec-hids restart

してみる

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4