# プラグイン: 最小構成 (Linux)

**想定読者:** Linuxエンドポイントに常駐型の管理プラグインを登録する統合担当者。

本ページは[プラグイン: 最小構成 (Windows)](/keeperpam/jp/endpoint-privilege-manager/integrations/examples/plugin-minimal-windows.md) のLinux向け版です。プラグインの構造と各フィールドの意味は同じで、違いはバイナリパス、`supportedPlatforms`、およびLinux特有の署名とパーミッションの考慮です。各フィールドの詳しい説明は、上記のWindows版ページを先に読み、本ページではLinuxで変わる点のみを扱います。

## プラグインのJSON <a href="#the-plugin-json" id="the-plugin-json"></a>

```json
{
  "id": "MyBridge",
  "name": "My Bridge",
  "description": "Long-running bridge component.",
  "version": "1.0.0",

  "pluginType": "Executable",
  "executablePath": "bin/MyBridge/MyBridge",
  "supportedPlatforms": ["Linux"],

  "Subscription": {
    "Topic": "MyBridge",
    "Qos": 2,
    "CleanSession": true
  },

  "metadata": {
    "mqttRole": ["subscriber", "publisher"],
    "mqttTopics": {
      "publish": ["KeeperLogger"],
      "subscribe": ["MyBridge", "MyBridge/Commands/+"]
    }
  },

  "startupPriority": 60,
  "autoStart": true,
  "executionContext": "Service",
  "requiresMonitoring": true,
  "autoRestart": true
}
```

## 変更する箇所 <a href="#what-to-change" id="what-to-change"></a>

フィールド自体はWindows版と同じです。Linux固有の置き換えは以下のとおりです。

<table><thead><tr><th width="276.6666259765625">フィールド</th><th>内容</th></tr></thead><tbody><tr><td><code>id</code></td><td>ファイル名と一致する安定した一意の識別子 (<code>"id": "MyBridge"</code> なら <code>MyBridge.json</code>)。</td></tr><tr><td><code>executablePath</code></td><td>エージェントルートからの相対パスで、拡張子 <code>.exe</code> は付けません。Linuxでのエージェントのデフォルトルートは <code>/opt/KeeperPrivilegeManager</code> のため、<code>bin/MyBridge/MyBridge</code> は <code>/opt/KeeperPrivilegeManager/bin/MyBridge/MyBridge</code> に解決されます。インストールルートは管理者へ確認してください。</td></tr><tr><td><code>supportedPlatforms</code></td><td>Linux専用なら <code>["Linux"]</code>。同一JSONで複数OSを扱う場合は <code>["Linux", "Windows", "macOS"]</code> も可能ですが、OSごとにファイルを分けた方が保守しやすいことが多いです。</td></tr><tr><td><code>Subscription.Topic</code></td><td>当該プラグインの主たるMQTTトピック。慣例としてプラグインの <code>id</code> を使います。</td></tr><tr><td><code>metadata.mqttTopics.publish</code></td><td>バイナリがパブリッシュするすべてのトピック。ログメッセージを出す場合は <code>KeeperLogger</code> を含めます。</td></tr><tr><td><code>metadata.mqttTopics.subscribe</code></td><td>主たる <code>Subscription.Topic</code> 以外にバイナリがサブスクライブするすべてのトピック。</td></tr></tbody></table>

**拡張子 `.exe` は付けない:** `executablePath` とディレクトリ名の両方で、バイナリ名に拡張子はありません。Linuxでは慣例として小文字の `mybridge` なども使われますが、エージェントは指定した名前をそのまま解決します。

**ファイルのパーミッション:** オーケストレーターが起動する前に、バイナリがエージェントのサービスアカウントから実行可能である必要があります。

```bash
chmod +x /opt/KeeperPrivilegeManager/bin/MyBridge/MyBridge
```

エージェントが特定の非rootユーザーで動いている場合は、そのユーザーがバイナリと親ディレクトリに対して読み取りおよび実行権限を持つことも確認します。

**Linuxでの署名:** WindowsやmacOSのようなOS全体で一律のバイナリ署名要件はありません。エージェントのプロセス信頼は、主としてオーケストレーターがバイナリを起動した事実に基づきます。手動起動ではなく常にエージェント経由で起動することが、コード署名より重要です。IMAやGPG署名パッケージなどを運用で使う場合は、他コンポーネントと同様にそれらに合わせます。MQTTやプラグイン設定へ、オーケストレーター起動以外の文脈からアクセスさせる必要がある場合は、`appsettings.json` の `Settings:AlternativeSignatures` に証明書のサムプリントを追加します。

**`autoRestart` とサービス管理:** LinuxではKEPMエージェントは多くの場合 systemd サービスとして動きます。`autoRestart: true` でプラグインが異常終了した場合、オーケストレーターが systemd とは独立に再起動します。短時間での再起動ループはログ量とCPU負荷が大きくなり得ます。想定どおりの停止ではきれいに終了し、終了前に明確なメッセージをログへ出して、クラッシュと意図的停止を区別できるようにします。

## デプロイ前に <a href="#before-you-deploy" id="before-you-deploy"></a>

1. `executablePath` が解決する場所へバイナリを置き、`chmod +x` で実行権限を付与します。
2. JSONファイルを `{AgentRoot}/Plugins/MyBridge.json` に置き、ファイル名を `id` と一致させます。
3. 環境ごとの正式な投入手順は管理者と確認します。
4. オーケストレーターが新しい登録を読み込むよう、エージェントサービスを再起動します。

```bash
sudo systemctl restart keeperprivilegemanager
```

## 検証 <a href="#verify" id="verify"></a>

エージェント再起動後、ログでプラグイン名を確認して起動したことを確かめます。続いて、起動時にバイナリ内からプラグイン設定が取得できるかを確認します。

```bash
curl -s https://127.0.0.1:6889/api/PluginSettings/MyBridge \
  --cert /path/to/client.pem \
  --key /path/to/client.key \
  --cacert /path/to/ca.pem
```

この呼び出しにはプラグイン階層の認証が必要で、エージェントが起動したプロセス以外のシェルから実行すると `403` になります。起動時のスモークテストとして、同等の呼び出しをプラグインバイナリ内から実行します。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeperpam/jp/endpoint-privilege-manager/integrations/examples/plugin-minimal-linux.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
