[![](https://openthread.io/static/images/icon-github.svg)View source on GitHub](https://github.com/openthread/ot-docs/tree/main/site/en/guides/commissioner/build.md)

This guide covers the basic build and configuration of OpenThread Commissioner
(OT Commissioner). Upon completion of this procedure, you'll have an OT
Commissioner CLI executable and a static Commissioner library.

## Set up OT Commissioner

1. Clone the OT Commissioner repository:

       git clone https://github.com/openthread/ot-commissioner

   <br />

2. Install dependencies:

       cd ot-commissioner
       ./script/bootstrap.sh

   <br />

## Build OT Commissioner

OT Commissioner installs to the `/usr/local` directory. If you'd like to change
your installation directory, set `-DCMAKE_INSTALL_PREFIX`.

> [!NOTE]
> **Note:** If you change the default installation directory, you'll need to update `$PATH` to run `commissioner-cli`. This guide uses an Environment variable to work for both default and custom installations.

1. Build OT Commissioner:

       mkdir build
       cd build
       cmake -DCMAKE_INSTALL_PREFIX=/usr/local -GNinja ..
       ninja -j1

   <br />

2. Create an Environment variable to run `commissioner-cli` in the next step:

       export COMMISSIONER_CLI=/usr/local/bin/commissioner-cli

   <br />

3. *Optional*. Run unit tests:

       ./tests/commissioner-test

   <br />

## Install OT Commissioner

OT Commissioner installs the following to your installation directory:

- OT Commissioner library and header files
- OT Commissioner CLI executable binary
- Default configuration files and credentials
- Scripts to run OT Commissioner CLI as daemon

    sudo ninja install

Verify the installation by checking the help menu.

    $COMMISSIONER_CLI -h

If you installed to the `/usr/local` directory, `commissioner-cli` is available
from the command line.

    commissioner-cli -h

## Configuration

The OT Commissioner CLI supports both Thread 1.2 Commercial Commissioning Mode
(CCM) and Thread 1.1 commissioning (Non-CCM). To connect to different Thread
networks, a JSON configuration file is needed to start OT Commissioner CLI:

- `ccm-config.json` --- The default configuration file for CCM Thread Network.
- `non-ccm-config.json` --- The default configuration file for Non-CCM Thread Network.

By default, these configuration files are installed in `/usr/local/etc/commissioner`. You can
also view sample files on the [ot-commissioner GitHub repository](https://github.com/openthread/ot-commissioner/tree/main/src/app/etc/commissioner).

### CCM configuration

To connect to a CCM Thread network, update these fields in `ccm-config.json`:

| Field | Description |
|---|---|
| `DomainName` | Unique identifier within the Enterprise Domain. |
| `PrivateKeyFile` | The private key file in PEM format. |
| `CertificateFile` | The certificate file in PEM format. |
| `TrustAnchorFile` | The trust anchor file in PEM format. |

These key and certificate files are used to establish secure sessions between
the Commissioner and Border Agent.

> [!NOTE]
> **Note:** If you changed the default installation directory, you'll need to update `"ThreadSMRoot" : "/usr/local/etc/commissioner"`.

### Non-CCM configuration

The Pre-Shared Key `PSKc` is used to establish a secure session between the
Commissioner and Border Agent. To connect to a Non-CCM Thread network, you
can set your `PSKc` from the OT Commissioner CLI. For more information,
refer to [External Commissioning](https://openthread.io/guides/border-router/external-commissioning/index.md).

### Logging

When you run `pi@raspberrypi: commissioner-cli` from the command line,
OT Commissioner creates a `commissioner.log` file in the current working
directory, for example `/home/pi/commissioner.log`. In the JSON configuration
file, you can configure your `LogFile` path, logging level, and other log
settings.

### Load configuration

To start OT Commissioner with your configuration settings:

    commissioner-cli /usr/local/etc/commissioner/ccm-config.json

> [!NOTE]
> **Note:** If you're using the default configuration settings in the `non-ccm-config.json` file, you don't need to pass it to `commissioner-cli`.

## Commission a joiner

To use OT Commissioner to commission a joiner, refer to [External
Commissioning](https://openthread.io/guides/border-router/external-commissioning/index.md).