junos_user
Experimental. A local account on a Juniper Junos device: its login class, password and SSH keys. Conn3x won’t demote or delete the account it logs in as.
Experimental. Network devices are new, and this module may change between releases. It’s tested against vJunos-switch 26.2R1.7 on a lab VM, not yet in CI.
Use junos_user to keep a local account on a Juniper Junos device: its login class, its password and its SSH keys. The change goes in like every Junos step does, once per device per circuit; see junos_config.
The password never reaches the device or state as text. Conn3x hashes password_wo on your machine, sends the salted SHA-512 hash as encrypted-password, and keeps only an HMAC of that hash in state, so a refresh can tell whether the account still holds your password without knowing it. A password changed on the device by hand shows as drift.
ssh_keys is the account’s whole set of keys: a key that isn’t listed is deleted. Leave it unset to leave the keys alone.
Conn3x won’t delete the account it logs in as, or move it out of super-user. Removing the step deletes the account, as with every step that grants access, unless on_remove = "forget".
Example usage
Section titled “Example usage”Give the password from an ephemeral variable, so it stays out of state and plan files:
step "alice" { junos_user { name = "alice" class = "operator" password_wo = "use-an-ephemeral-variable-here" ssh_keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyOnlyForDocs alice@laptop"] }}Arguments
Section titled “Arguments”| Name | Type | Required | Description |
|---|---|---|---|
class |
string | Yes | Its login class, such as super-user, operator or read-only. Junos requires one. |
name |
string | Yes | The account name. Not root. |
on_remove |
string | No | “delete” (default) deletes the account when the step goes, as with every step that grants access; “forget” leaves it. |
password_wo |
string | No | Write-only: the password, never kept in state. Conn3x hashes it here and sends the device the salted SHA-512 hash, as encrypted-password, so the password itself never reaches the CLI; a new value plans a change through password_hmac. Unset leaves the account’s password alone. |
ssh_keys |
list of string | No | The account’s public keys, one line each, such as “ssh-ed25519 AAAA… alice@laptop”. Keys not listed are deleted; [] deletes them all, and unset leaves them alone. |
Read-only attributes
Section titled “Read-only attributes”Conn3x sets these; reference them as conn3x_junos_user.<circuit>__<step>["<host>"].<name>.
| Name | Type | Description |
|---|---|---|
in_sync |
bool | Whether the account matched at the last refresh. |
password_hmac |
string | An HMAC of the hash the device should hold for password_wo, keyed outside state. A new password plans a change, and a refresh finds an account with another one out of sync. |
revision |
string | Changes each time Conn3x changes this on the host. Handlers watch it. |
A step lowers to the conn3x_junos_user resource, one instance per host, and connects with its circuit’s ssh block.