Skip to content

Targets ​

Targets are named devices, kept in ~/.config/net-netconf/targets.json. Use $NNC_TARGETS or --targets <path> (also -t, --config or -C) to read another file.

json
{
  "router1": {
    "host": "router1",
    "port": 830,
    "username": "netconf",
    "password": { "file": "~/.config/net-netconf/router1.pass" },
    "jumpHost": { "host": "jump1", "username": "me", "agent": true },
    "profile": "nokia-7210-sas",
    "readOnly": true
  }
}

The fields match the library's ssh() options. targets lists them at the prompt.

Credentials ​

  • Passwords come from { "file": … }, { "env": … } or { "prompt": true }. Prompting is the default when there's no key or agent. They never come from the command line, or from the targets file itself.

  • SSH agent: with no agent field, the agent at $SSH_AUTH_SOCK is used only if the target has no password and no privateKey. "agent": true uses it alongside them, and "agent": false never uses it.

    This differs from OpenSSH, which offers every agent key whatever else is configured. Every refused key counts against a device's failed-login limit, and routers lock accounts out.

Host keys ​

Host keys are checked against ~/.ssh/known_hosts by default. A target can name another file with knownHosts. "hostKey": "insecure-accept-any" turns verification off. nnc warns about this, and the prompt shows [insecure] for the whole session.

Or pin the key. hostKey, on a target or a jump host, may be a SHA256: fingerprint as ssh-keygen -lf prints it, a public key line, or a list of either (any one entry is accepted):

json
{
  "lab1": {
    "host": "192.0.2.10",
    "username": "netconf",
    "password": { "prompt": true },
    "hostKey": "SHA256:5jz6plf3ShmbYvtqc5V1AkhDFzVWxR8aNWO1b+iLZnc"
  }
}

Only the pin is checked, so knownHosts can't be used with one. A malformed pin is an error when the targets file is read. A key that doesn't match is refused before any credentials are sent, naming the fingerprint received and the targets file to update. status shows the fingerprint followed by (pinned).

Jump hosts ​

jumpHost is one jump host, or a list connected in order. Each hop has its own username, authentication and host-key check. A failure names the hop at fault.

Device profiles ​

profile names a built-in or loaded profile. Without it, nnc auto-detects among the built-in profiles. profilesDir adds a directory of your own profiles.

Read-only ​

"readOnly": true, or connect <target> --read-only, makes the session refuse anything that could change state, before it's sent:

  • every operation whose descriptor says it changes state: edit-config, lock, commit, set, remove, begin, …
  • device profile operations, unless the profile marks them "mutates": false
  • rpc <xml> whose root element isn't a known read-only operation, unless the target lists it in "allowRpcs": [...]
  • framed and raw sessions, because nnc can't tell what you'll type in them

Read-only can't be turned off mid-session. To make changes, connect to a target that isn't read-only.

Session options ​

maxInFlight, maxMessageBytes, parseLimits, capabilityCheck, namespaces and yang are passed to the library's connect() under the same names. yang takes modules (a list of directories of YANG modules) and requireSchema, for JSON:

json
"yang": { "modules": ["/home/me/yang/alu-conf-r13"] }

TLS ​

json
{
  "router2": {
    "transport": "tls",
    "host": "router2",
    "cert": "~/.config/net-netconf/me.pem",
    "key": "~/.config/net-netconf/me.key",
    "ca": "~/.config/net-netconf/lab-ca.pem"
  }
}

cert, key, and one of ca, fingerprint or insecure are required. passphrase is a password source for the key, and serverName is the name the server certificate must carry, if it isn't host.

Simulated devices ​

A sim target reaches a device that runs in the same process or web page, such as the library's fake server, instead of an SSH or TLS endpoint:

json
{
  "lab": { "transport": "sim", "device": "router", "readOnly": true }
}

device names the simulated device, and defaults to the target's name. A sim target has no host or port, and the SSH and TLS fields are refused on it. The rest works as over SSH: profiles, read-only, the trace, and framed and raw sessions. status and targets show it as sim:router.

The nnc command provides no simulated devices. A program that runs nnc on its own host, from @node-net/nnc/core, provides them with simTransports.

Without a targets file ​

nnc> connect admin@10.1.2.3:830
nnc> connect 10.1.2.3 --tls --cert me.pem --key me.key --ca ca.pem

nnc prompts for a password unless an SSH agent has a key. An ad hoc session isn't read-only unless you add --read-only.

Released under the MIT Licence.