> 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/device-approvals/commander-cli.md). Agents can also search and read this documentation through its [MCP server](https://docs.keeper.io/~gitbook/mcp).

# CLI Approvals

Commander Approvals

## Commander Method for Automated Approvals

Keeper Commander, our CLI and SDK platform is capable of performing Admin Device Approvals for automated approval without having to login to the Admin Console. Admin approvals can be configured on any computer that is able to run Keeper Commander (Windows, Linux or MacOS).

This method does not require inbound connections from the Keeper cloud, so it could be preferred for environments where ingress ports cannot be opened. This method uses a polling mechanism (outbound connections only).

## Set up the Automation

### Install Keeper Commander

Please see the Installation Instructions [here](https://docs.keeper.io/keeperpam/commander-cli/commander-installation-setup.md).

### Run Commander

By default, Commander will attempt store its configuration using a cryptographic method available on the host OS. In order to set up CLI Approvals, we need to surface this configuration file as a local JSON.

***

1. Open a terminal on the host OS and run the following command:

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

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

{% endcode %}

{% hint style="info" %}
Before version 18.0.3, Commander always created a JSON configuration file in `{user_profile}.keeper\config.json`.
{% endhint %}

***

2. Once in Commander, log into your administrator account:

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

Commander supports SSO, Master Password and 2FA. For the purpose of automation, we recommend creating a dedicated Keeper Admin service account that is specifically used for device approvals. This ensures that any changes made to the user account (such as policy enforcements) don't break the Commander process.

***

3. Register your device with Persistent login and quit:

{% 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 %}

***

After logging in, you should see the JSON file created under `path\to\device-approval-config.json`. You can still log into Commander normally without using the `--config` argument, this will use a separate configuration file.

### Convert Commander into an Automatic Runner

Commander supports an automation mode that will run commands (approvals in this case) every *n* number of seconds. To set this up, you must update the dedicated JSON configuration file created above.

For Device Approvals only, add the following lines :

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

For Device Approvals *and* Team approvals, add `team-approve` to the `commands` list:

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

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

{% endcode %}

Depending on the cryptography support from your host OS, the full JSON file should look like this:

{% tabs %}
{% tab title="With Cryptography" %}
{% 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="Without Cryptography" %}
{% 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 %}

After saving the file, running Commander with that configuration will run the commands periodically based on the interval specified. Example:

```
$ 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" %}
You can use seconds as the value (e.g. 60 for 60 seconds) or numbers and letters (e.g. 1m for one minute, 5h for 5 hours, and 7d for 7 days).
{% endhint %}

## Schedule the Execution

### With Linux (CRON)

On Linux, Commander typically runs from within a Python virtual environment, e.g.:

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

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

{% endcode %}

You can schedule Commander to run at boot using 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 %}

Or if you prefer editing the `/etc/crontab` file, use this syntax:

{% 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 %}

### With Windows (Task Scheduler)

* Create a Basic Task
* Under **Trigger**, select "**When the computer starts**"
* Under **Action**, select "**Start a program**"
* Under **Start a program**, enter `keeper` as **Program**, and `--config "C:\path\to\device-approval-config.json"` in **Add arguments**<br>

<figure><img src="https://2503956294-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MB_i6vKdtG6Z2n6zWgJ%2Fuploads%2FlagBsvT92cRxAqX7fFBV%2Fimage.png?alt=media&amp;token=c54a532b-6580-4b3f-8f96-39a485980f75" alt=""><figcaption></figcaption></figure>

* After completing the Basic Task creation, open its properties. Under **General**, enable "**Run whether the user is logged on or not**".

***

On reboot, Commander should automatically run, executing commands at the specified interval.

Monitor the automation host and review its approval activity regularly. Restrict access to the service account and configuration file. Test policy changes before applying them to the approval workflow.


---

# 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/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.
