---
title: "3-1　Linux"
canonical: "https://manual.shadan-kun.com/space/KSK2INST/14155845/3-1%E3%80%80Linux"
format: markdown
---
#### STEP1　エージェントキーをインポート

1. セットアップを開始

```
# /var/shadan-kun/bin/manage_agents
```


2.「i」を入力して[Enter]

```
****************************************
* OSSEC HIDS v3.7 Agent manager. *
* The following options are available: *
****************************************
(I)mport key from the server (I).
(Q)uit.
Choose your action: I or Q: i
```


3. エージェントキー文字列を入力（ペースト）して[Enter]

```
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): ********************************
```

> ℹ️ **参照**
> ℹ️ 
> ℹ️ - エージェントキーの発行・確認は[https://csc-document.atlassian.net/wiki/spaces/KSK2INST/pages/14026079](https://csc-document.atlassian.net/wiki/spaces/KSK2INST/pages/14026079)を参照してください。


4. 内容を確認して「y」を入力して[Enter]

```
Agent information:
ID:xxx
Name:hostxxxxxx
IP Address:any
Confirm adding it?(y/n): y
```


5. [Enter]でインポートメニューから離脱

```
Added.
** Press ENTER to return to the main menu. [Enter]
```


6.「q」を入力して[Enter]

```
****************************************
* OSSEC HIDS v3.7 Agent manager. *
* The following options are available: *
****************************************
(I)mport key from the server (I).
(Q)uit.
Choose your action: I or Q: q
```


7. エージェントキーのインポートが完了

```
** You must restart OSSEC for your changes to take effect.
manage_agents: Exiting ..
```


#### STEP2　設定編集

1. ossec.confを編集

```none
# vi /var/shadan-kun/etc/ossec.conf
```


2. 攻撃遮断くん監視センターの情報を入力

```
<ossec_config>
  <client>
    <server-hostname>（※1）</server-hostname>
    <port>（※1）</port>
  </client>
```

> ℹ️ **参照**
> ℹ️ 
> ℹ️ - （※1）監視センターのホスト名およびポート番号は管理画面から確認します。詳細は[https://csc-document.atlassian.net/wiki/spaces/KSK2INST/pages/14026079](https://csc-document.atlassian.net/wiki/spaces/KSK2INST/pages/14026079)を参照してください。


3. 監視対象ログファイルの確認と追記

デフォルトでは次の設定が含まれます。

```
【RHEL版パッケージ】
<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/messages</location>
</localfile>

<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/secure</location>
</localfile>

<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/maillog</location>
</localfile>

【Ubuntu版パッケージ】
<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/auth.log</location>
</localfile>

<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/syslog</location>
</localfile>

<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/dpkg.log</location>
</localfile>
```


監視対象にWebアプリケーションのアクセスログとエラーログを追記します

**・記載ルール**

```
<localfile>
  <log_format>ログの種類（Webの場合：apache、システムログの場合：syslog）</log_format>
  <location>ログのパス（絶対パス）</location>
</localfile>
```


**・Apacheの記載例**

```
<localfile>
  <log_format>apache</log_format>
  <location>/var/log/httpd/error_log</location>
</localfile>

<localfile>
  <log_format>apache</log_format>
  <location>/var/log/httpd/access_log</location>
</localfile>
```


4. エージェントプログラムの再起動を実施

```
# /var/shadan-kun/bin/ossec-control restart
```