> For the complete documentation index, see [llms.txt](https://docs.keeper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keeper.io/sso-connect-cloud/jp/device-approvals/commander-cli.md).

# CLIを使用した承認

コマンダーを使用した承認

## コマンダー方式による自動承認

KeeperコマンダーはCLIおよびSDKプラットフォームであり、Keeper管理コンソールにログインしなくても、管理者によるデバイス承認を自動化できます。Keeperコマンダーが実行可能なコンピュータ (Windows、Linux、macOS) であれば、管理者承認を設定できます。

この方式ではKeeperクラウドからの着信接続は不要なため、インバウンドポートを開けられない環境に適しています。ポーリング方式 (送信接続のみ) を使用します。

## 自動化の設定

### Keeperコマンダーのインストール

インストール手順は[こちら](https://docs.keeper.io/keeperpam/jp/commander-cli/commander-installation-setup.md)をご参照ください。

### コマンダーの実行

コマンダーは、デフォルトではホストOSの暗号化機能を使って構成を保存します。CLIによる承認を設定するには、この構成ファイルをローカルのJSONファイルとして出力する必要があります。

***

1. ホストOSでターミナルを開き、以下のコマンドを実行します。

{% code overflow="wrap" expandable="true" %}

```bash
keeper shell --config "path\to\device-approval-config.json"
```

{% endcode %}

{% hint style="info" %}
バージョン18.0.3より前のコマンダーでは、JSON構成ファイルが常に `{user_profile}.keeper\config.json` に作成されていました。
{% endhint %}

***

2. コマンダーが起動したら、管理者アカウントでログインします。

```
login my_service_user@acme-demo.com
```

コマンダーでは、SSO、マスターパスワード、2FAを使用できます。自動化のため、デバイス承認専用のKeeper管理サービスアカウントを作成することを推奨します。これにより、ユーザーアカウントへの変更 (強制適用ポリシーなど) によってコマンダーの処理が中断されることを防げます。

***

3. 持続的ログインでデバイスを登録し、コマンダーを終了します。

{% code overflow="wrap" expandable="true" %}

```
this-device register
this-device persistent-login on
this-device ip-auto-approve on
this-device timeout 30d
quit    
```

{% endcode %}

***

ログインすると、`path\to\device-approval-config.json` にJSONファイルが作成されます。`--config` 引数を付けずに通常どおりログインすることもできますが、その場合は別の構成ファイルが使用されます。

### コマンダーを自動実行ランナーにする

コマンダーには、n秒ごとにコマンド (ここでは承認) を実行する自動化モードがあります。設定するには、上記で作成した専用のJSON構成ファイルを編集します。

デバイス承認のみの場合は、以下の行を追加します。

```json
"commands":["enterprise-down","device-approve --approve"],
"timedelay": 20
```

デバイス承認とチーム承認の両方を行う場合は、`commands` リストに `team-approve` を追加します。

{% code overflow="wrap" expandable="true" %}

```json
"commands":["enterprise-down","device-approve --approve", "team-approve"],
"timedelay": 20
```

{% endcode %}

ホストOSの暗号化対応状況に応じて、JSONファイル全体は以下のようになります。

{% tabs %}
{% tab title="暗号化あり" %}
{% code overflow="wrap" expandable="true" %}

```json
{
   "config_storage": "os-keychain://abc123",
   "commands": ["enterprise-down", "device-approve --approve", "team-approve"],
   "timedelay": 20
}
```

{% endcode %}
{% endtab %}

{% tab title="暗号化なし" %}
{% code overflow="wrap" expandable="true" %}

```json
{
  "config_storage": "file",
  "server": "keepersecurity.com",
  "device_token": "abc123",
  "private_key": "abc123",
  "user": "my_service_user@acme-demo.com",
  "clone_code": "abc123",
  "commands": ["enterprise-down", "device-approve --approve", "team-approve"],
  "timedelay": 20
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

ファイルを保存した後、その構成でコマンダーを実行すると、指定した間隔でコマンドが定期的に実行されます。以下は、その実行例です。

```
$ keeper shell --config "path\to\device-approval-config.json"
Executing [enterprise-down]...
Password: 
Logging in...
Syncing...
Executing [enterprise-down]...
Executing [device-approve --approve]...
2020/09/20 21:59:47 Waiting for 20 seconds
Executing [enterprise-down]...
```

{% hint style="info" %}
値には秒数 (60秒の場合は60) または数字と文字の組み合わせ (1分の場合は1m、5時間の場合は5h、7日間の場合は7d) を使用できます。
{% endhint %}

## 実行のスケジュール設定

### Linuxの場合 (CRON)

Linuxでは、通常、コマンダーはPython仮想環境内で実行します。以下はその例です。

{% code overflow="wrap" expandable="true" %}

```bash
source keeper-env/bin/activate
keeper shell --config /root/device-approval-config.json
```

{% endcode %}

Cronを使用して、起動時にコマンダーを実行するようスケジュールできます。

{% code overflow="wrap" expandable="true" %}

```
crontab -e
... # add the following line to the end of your file
@reboot /root/keeper-env/bin/keeper --config /root/device-approval-config.json
```

{% endcode %}

`/etc/crontab` ファイルを編集する場合は、以下の構文を使用します。

{% code overflow="wrap" expandable="true" %}

```
nano /etc/crontab
... # add the following line to the end of your file
@reboot root /root/keeper-env/bin/keeper --config /root/device-approval-config.json
```

{% endcode %}

### Windowsの場合 (タスクスケジューラ)

* 基本タスクを作成
* **トリガー**で **\[コンピューターの起動時]** を選択
* **操作**で **\[プログラムの開始]** を選択
* **プログラムの開始**で、**プログラム/スクリプト**に `keeper`、**引数の追加**に `--config "C:\path\to\device-approval-config.json"` を入力

<figure><img src="https://1914737032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mfd2v-YT48Ljtykb8qm%2Fuploads%2Fgit-blob-f40f6cb129a485126798c1a7fa89e62a6ee5fdd3%2Fcommander-cli1.png?alt=media" alt=""><figcaption></figcaption></figure>

* 基本タスクの作成後、プロパティを開き、**\[全般]** で **\[ユーザーがログオンしているかどうかにかかわらず実行する]** を有効化

***

再起動すると、コマンダーが自動的に実行され、指定した間隔でコマンドが実行されます。

自動化ホストを監視し、承認アクティビティを定期的に確認してください。サービスアカウントと構成ファイルへのアクセスを制限してください。承認ワークフローに適用する前に、ポリシーの変更をテストしてください。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.keeper.io/sso-connect-cloud/jp/device-approvals/commander-cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
