Skip to main content
Documentation

Identity and Credentials

Nexigon Agent authenticates a device to Nexigon Hub with three pieces of information: credentials that select the project, a TLS certificate with its private key, and a fingerprint that identifies the device. Device Authentication describes how Nexigon Hub checks them. This page describes where the agent gets them.

Credentials

The credentials consist of a Nexigon Hub URL and a deployment token. The agent obtains them in one of two ways:

  • Static credentials: hub-url and token in the configuration. Every device with the same configuration joins the same project.
  • Saved credentials: The agent reads credentials.json from its data directory, /var/lib/nexigon/agent by default. The agent writes this file after provisioning, with a deployment token bound to the device.

Set both hub-url and token, or neither; setting only one is an error. Static credentials take precedence over saved ones. Without either, the agent fails to start, unless provisioning is enabled.

Device Certificate

The agent authenticates its connection with a TLS certificate, by default /etc/nexigon/agent/ssl/cert.pem, and its private key, by default /etc/nexigon/agent/ssl/key.pem. If neither exists, the agent generates a key and a self-signed certificate when it starts. Nexigon Hub accepts the first certificate of a new device automatically if the deployment token enables Auto Accept; otherwise, an operator accepts it.

Keep the certificate, the key, and the data directory on persistent storage that system updates do not replace, and exclude them from images shared by several devices. If a device loses its key, it creates a new certificate, which an operator must accept before the device can connect again.

Device Fingerprints

The device fingerprint identifies a device across certificate and credential changes. The agent computes it from the output of the fingerprint script set in fingerprint-script. The output must be unique to the device and stable across reboots, updates, and credential changes. Send diagnostics to stderr, so that they do not change the fingerprint.

For example, the following script uses /etc/machine-id:

/usr/libexec/nexigon/nexigon-device-fingerprint
#!/usr/bin/env bash

set -euo pipefail

cat "/etc/machine-id"

This requires a machine ID that is generated for each device and preserved across updates. Devices cloned from an image with a populated /etc/machine-id would share the same fingerprint. If storage can be replaced, use an identity source that survives the replacement, such as a hardware serial number.

Provisioning Mode

In provisioning mode, an unpaired agent accepts a one-time provisioning token over a local HTTP endpoint and exchanges it for device-bound credentials. The endpoint runs only when [provisioning] is enabled and the agent has neither static nor saved credentials.

A token that contains a Nexigon Hub domain, such as eu.nexigon.cloud,<key>, selects that instance. A token without a domain is tried at each of the configured endpoints in order, by default the EU and US instances of Nexigon Cloud; set endpoints to your own instance when you host Nexigon Hub yourself.

After pairing, the agent writes credentials.json with mode 0600, protects the data directory with mode 0700, closes the endpoint, and connects. Later starts reuse the saved credentials. If they are missing, invalid, or unreadable while provisioning is disabled, the agent fails to start instead of reopening the endpoint.

The endpoint uses plaintext HTTP and listens on 0.0.0.0:6947 by default. Use it only on a trusted network, and set bind = "127.0.0.1:6947" to accept tokens only from the device itself. Provision Devices walks through the complete workflow.

Server Certificates

The agent verifies the certificate of Nexigon Hub and of every other HTTPS endpoint, such as storage URLs for repository assets, against the operating system’s trust store. On Linux, the ca-certificates package usually provides it, so keep the package up to date in device images. For a self-hosted Nexigon Hub with a certificate from your own certificate authority, add that authority to the trust store.

Hardware-Bound Keys

A hardware-bound key stays in a TPM, a PKCS#11 token, or device firmware, which signs with it on request, so that a copy of the device’s storage does not contain it. Use Hardware-Bound Device Keys explains what this protects against and shows how to create keys and signer scripts for TPM 2.0, PKCS#11 tokens, and the Raspberry Pi firmware.

The agent uses a hardware-bound key through a signer script, an executable that you provide. With [signer] configured, the agent:

  • Reads the public key from the script when it starts, and has the script sign a new self-signed certificate if none exists at ssl-cert.
  • Has the script sign each TLS handshake with Nexigon Hub.
  • Never creates or reads a key file. Setting both ssl-key and [signer] is an error.

An existing certificate, for example one issued by your own certificate authority, must contain the signer’s public key; otherwise, the agent fails to start. The agent also fails to start if reading the public key or signing a new certificate fails or times out. If signing fails during a TLS handshake, the agent retries as after other connection failures. On a timeout, the agent kills the script and every process that it started, which could otherwise keep holding the hardware.

Signer Script Protocol

The agent runs the signer script with the operation as its only argument:

OperationInputOutput on stdout
public-keyNoneThe public key as DER-encoded X.509 SubjectPublicKeyInfo.
signMessage on stdinThe DER-encoded ECDSA signature over the message hash.

The key must be an ECDSA key on the curve P-256 or P-384. The script hashes the message itself, with SHA-256 for P-256 keys and with SHA-384 for P-384 keys. Both outputs are binary DER. Many tools write other formats by default, such as PEM public keys or signatures as concatenated r and s values, and need options to write DER. The agent verifies every signature with the public key and reports a signature that does not verify as an error.

When an operation fails, the script must exit with a non-zero status and should describe the failure on stderr. The agent includes the exit status and stderr in its error, so specific messages, such as a missing key or a locked token, make failures easy to tell apart.

The script runs as the user that runs nexigon-agent. For nexigon-agent run, this is the service’s user. Commands such as nexigon-agent device id connect to Nexigon Hub themselves when the agent is not running, and then run the script as the user who invoked them. Each of these users needs access to the hardware.