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:
- A provisioning image with provisioning mode enabled. You flash it, boot the device, and send it a token.
- 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:
- A project in Nexigon and permission to manage its tokens.
- A device image with Nexigon Agent, as built in Build an Image with Rugix Bakery or Build an Image with Yocto, with a system update integration.
- A production image published to a repository.
- A machine that can reach the device on TCP port 6947.
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:
fingerprint-script = "/usr/libexec/nexigon/nexigon-device-fingerprint"
[provisioning]
enabled = trueThe build integrations generate this configuration:
- Rugix Bakery: Set the
provisioningparameter of thenexigon/nexigon-agent-configrecipe to"true". The recipe then ignores the credentials in.env. - Yocto: Set
NEXIGON_PROVISIONING = "1"and leaveNEXIGON_HUB_URLandNEXIGON_TOKENempty.
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
-
Open Devices in the intended project and choose Add Device.
-
In the Provisioning Token tab, copy the displayed command.
-
Replace
DEVICE_ADDRESSin 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/pairThe 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.
-
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:
fingerprint-script = "/usr/libexec/nexigon/nexigon-device-fingerprint"
[provisioning]
enabled = falseOmit 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:
#!/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
EOFGive 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
| Symptom | What to Check |
|---|---|
| Connection refused on port 6947 | The 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 token | Copy the complete value without changes. Generate another token if it has expired or was already redeemed. |
| Nexigon Hub connection or TLS error | The device reaches Nexigon Hub over HTTPS and trusts its certificate. Check the domain in the copied value. |
| Device fingerprint is already registered | Another 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 stored | The agent can write to its data directory on persistent storage. |