Skip to main content
Documentation

Provision Devices

Enroll devices in production without building credentials into their image. In provisioning mode, Nexigon Agent waits on the local network for a provisioning token that you generate in Nexigon for one device. The token is valid for five minutes and can be redeemed once. The agent exchanges it for credentials bound to the device and saves them for later connections.

A typical flow uses two images:

  1. A provisioning image with provisioning mode enabled. You flash it, boot the device, and send it a token.
  2. A production image with provisioning mode disabled. Once the device is paired, it installs this image through its system update integration and keeps the saved credentials.

Keep provisioning disabled in the production image. A production device that loses its credentials then fails to start instead of reopening the enrollment endpoint to anyone on the network.

Before You Start

You need:

The provisioning endpoint uses plain HTTP and listens on all IPv4 interfaces by default. Provision devices on a trusted network.

Build a Provisioning Image

Configure Nexigon Agent without hub-url and token, and enable provisioning:

/etc/nexigon/agent.toml
fingerprint-script = "/usr/libexec/nexigon/nexigon-device-fingerprint"

[provisioning]
enabled = true

The build integrations generate this configuration:

  • Rugix Bakery: Set the provisioning parameter of the nexigon/nexigon-agent-config recipe to "true". The recipe then ignores the credentials in .env.
  • Yocto: Set NEXIGON_PROVISIONING = "1" and leave NEXIGON_HUB_URL and NEXIGON_TOKEN empty.

The agent saves the credentials under /var/lib/nexigon/agent and keeps its TLS certificate and private key under /etc/nexigon/agent/ssl. Both directories must survive the switch to the production image, and the fingerprint script must return the same output in both images. The Rugix Bakery recipes and the meta-nexigon-rugix layer persist the directories. With RAUC, set NEXIGON_AGENT_DATA_DIR and NEXIGON_AGENT_SSL_DIR to a data partition.

Flash the image and boot the device. Check that the agent waits for a token, replacing DEVICE_ADDRESS with the device’s hostname or IP address:

curl --fail-with-body http://DEVICE_ADDRESS:6947/

A waiting agent returns {"status":"ready","endpoint":"/pair"}. Provisioning settings change the port, the bind address, the fallback Nexigon Hub endpoints, and the device name.

Pair the Device

  1. Open Devices in the intended project and choose Add Device.

  2. In the Provisioning Token tab, copy the displayed command.

  3. Replace DEVICE_ADDRESS in the command with the device’s address and run it from a machine that can reach the device:

    curl --data "eu.nexigon.cloud,PAIRING_KEY" http://DEVICE_ADDRESS:6947/pair

    The token in the command contains the domain of your Nexigon Hub instance, a comma, and the pairing key. The domain tells the agent where to redeem the key.

  4. A successful response contains "status":"paired", the Nexigon Hub URL, and the device ID. Choose Done in Nexigon and refresh the device list.

Nexigon Hub accepts the device’s first certificate automatically. If a token expires before you use it, choose Generate Another Token. Each device needs its own token.

Switch to the Production Image

Build the production image with provisioning disabled and the same fingerprint script:

/etc/nexigon/agent.toml
fingerprint-script = "/usr/libexec/nexigon/nexigon-device-fingerprint"

[provisioning]
enabled = false

Omit hub-url and token, so that the agent uses the saved credentials. With Yocto, build with NEXIGON_PROVISIONING = "0" and empty NEXIGON_HUB_URL and NEXIGON_TOKEN.

With Rugix Bakery, the nexigon/nexigon-agent-config recipe requires either provisioning or credentials. In the production layer, replace it with a recipe of your project that writes the configuration above, for example:

recipes/agent-config/steps/00-install.sh
#!/usr/bin/env bash

set -euo pipefail

mkdir -p /etc/nexigon
cat >/etc/nexigon/agent.toml <<'EOF'
fingerprint-script = "/usr/libexec/nexigon/nexigon-device-fingerprint"

[provisioning]
enabled = false
EOF

Give the recipe a recipes/agent-config/recipe.toml with a description, make the step executable, list agent-config in the layer instead of nexigon/nexigon-agent-config, and add your other agent settings to the file.

Publish the production image and deploy it to the paired device, for example by setting the device’s dev.nexigon.ota.config property to its release. After the update, check that the device is online and reports the production version.

Troubleshooting

SymptomWhat to Check
Connection refused on port 6947The agent runs with provisioning enabled and has no static or saved credentials. Check its bind address and the device’s firewall. The listener closes after pairing.
Invalid or expired provisioning tokenCopy the complete value without changes. Generate another token if it has expired or was already redeemed.
Nexigon Hub connection or TLS errorThe device reaches Nexigon Hub over HTTPS and trusts its certificate. Check the domain in the copied value.
Device fingerprint is already registeredAnother device in the project has the same fingerprint. Check that the fingerprint script returns a value unique to each device.
Credentials are missing or cannot be storedThe agent can write to its data directory on persistent storage.