1. General
1.1 Extract the NED package
1.2 Install the NED package
1.2.1 Local install
1.2.2 System install
1.3 Configure the NED in NSO
2. Optional debug and trace setup
3. Dependencies
4. Sample device configuration
5. Built in live-status actions
6. Built in live-status show
7. Limitations
8. How to report NED issues and feature requests
9. How to rebuild a NED
10. Configure the NED to use ssh multi factor authentication
1. General
This document describes the redhat-dir389 NED.
General info and considerations.
REDHAT-DIR389: This NED addresses Redhat Dir389 deployments
We will reffer to them throughout this document simply as "the device" or "the Redhat-DIR389 device".
The devices are expected to run RedHat, Fedora or derived Linux systems. Interaction with the device is done via CLI using SSH session encrypted with strong secure ciphers. Telnet is not supported.
Since the underlying OS is a Linux based system, unless otherwise requested, live status commands or RPCs are limited/not implemented.
Please make sure you have the right ned-settings configured as below at section 1.3.1 or refer to section 8 from NedSettings readme.
Additional README files bundled with this NED package
+---------------------------+------------------------------------------------------------------------------+
| Name | Info |
+---------------------------+------------------------------------------------------------------------------+
| README-ned-settings.md | Information about all run time settings supported by this NED. |
+---------------------------+------------------------------------------------------------------------------+
Common NED Features
+---------------------------+-----------+------------------------------------------------------------------+
| Feature | Supported | Info |
+---------------------------+-----------+------------------------------------------------------------------+
| netsim | yes | |
| | | |
| check-sync | yes | |
| | | |
| partial-sync-from | no | NED doesn't currently support partial sync-from |
| | | |
| live-status actions | no | NED doesn't currently support live-status actions or RPCs |
| | | |
| live-status show | no | NED doesn't currently support live-status show |
| | | |
| load-native-config | no | NED doesn't currently support load-native-config |
+---------------------------+-----------+------------------------------------------------------------------+
Verified target systems
+---------------------------+-----------------+--------+---------------------------------------------------+
| Model | Version | OS | Info |
+---------------------------+-----------------+--------+---------------------------------------------------+
| RedHat | | Linux | |
| | | | |
| Fedora | | Linux | |
| | | | |
| Centos | | Linux | |
+---------------------------+-----------------+--------+---------------------------------------------------+
1.1 Extract the NED package
It is assumed the NED package ncs-<NSO version>-redhat-dir389-<NED version>.signed.bin has already
been downloaded from software.cisco.com.
In this instruction the following example settings will be used:
NSO version: 6.0
NED version: 1.0.1
NED package downloaded to: /tmp/ned-package-store
Extract the NED package and verify its signature:
> cd /tmp/ned-package-store
> chmod u+x ncs-6.0-redhat-dir389-1.0.1.signed.bin
> ./ncs-6.0-redhat-dir389-1.0.1.signed.bin
In case the signature can not be verified (for instance if no internet connection),
do as below instead:
* Define ldap-secret:
* path: `<device-name>/ned-settings/redhat-dir389/ldap-settings/ldap-secret`
* ldap-secret is the directory 389 admin password defined for managing cn=Directory Manager ldap commands
* It basically represents the -w argument value from ldap commands used
---
Example :
```
admin@ncs(config)# devices device <device-name> ned-settings redhat-dir389 ldap-settings ldap-secret <LDAPADMIN-SECRET>
```
1.3.2 From redhat-dir389 v1.2.0 onwards, additional options are available:
* These additional options can be used to enable tls auth and define/customize various ldap commands parameters
admin@ncs(config-device-redhat-dir-1)# ned-settings redhat-dir389 ldap-settings ?
Possible completions:
bind-dn (-D) binddn : bind DN
host (-h) host : LDAP server
ldap-secret (-w) passwd : bind password (for simple authentication)
managed-dn-list Ldap basedn entries NED will manage at sync-from
port (-p) port : port on LDAP server
tls (-Z) : set Start TLS request; When false, simple auth (-xLLL) is used!
* Options are self explanatory as per the **389 Directory Server** official documentation.
* The intended design is to choose between tls and simple auth so that when tls flag s chosen, simple auth is deactivated.
In this case bind-dn should be set too to a privileged binddn, to use other than the default `"cn=Directory Manager"`.
* **NOTE** that when **tls** flag is used, the according flag for each NED-SETTING below will be used globally in all the NED operations.
* Otherwise, simple auth will be used, using `bind-dn` as `"cn=Directory Manager"` and **ignoring** any additional LDAP server local host and port settings.
1.3.3 Example of ned-settings configuration with tls enabled:
* **Commit updated configuration to save ned-settings:**
`admin@ncs(config)# commit`
* **Sync-from to collect data from device using the committed ned-settings:**
`admin@ncs(config)# devices device <device-name> sync-from`
* **Sample of correct initial ned-settings expected configuration:**
admin@ncs(config)# devices device dev-1 sync-from
result true
If the sync-from was not successful, check the NED configuration again.
2. Optional debug and trace setup
It is often desirable to see details from when and how the NED interacts with the device(Example: troubleshooting)
This can be achieved by configuring NSO to generate a trace file for the NED. A trace file
contains information about all interactions with the device. Messages sent and received as well
as debug printouts, depending on the log level configured.
NSO creates one separate trace file for each device instance with tracing enabled.
Stored in the following location:
The log level 'info' is used by default and the 'debug' level is the most verbose.
IMPORTANT:
Tracing shall be used with caution. This feature does increase the number of IPC messages sent
between the NED and NSO. In some cases this can affect the performance in NSO. Hence, tracing should
normally be disabled in production systems.
An alternative method for generating printouts from the NED is to enable the Java logging mechanism.
This makes the NED print log messages to common NSO Java log file.
IMPORTANT:
Java logging does not use any IPC messages sent to NSO. Consequently, NSO performance is not
affected. However, all log printouts from all log enabled devices are saved in one single file.
This means that the usability is limited. Typically single device use cases etc.
3. Dependencies
This NED has the following host environment dependencies:
Java 1.8 (NSO version < 6.2)
Java 17 (NSO version >= 6.2)
Gnu Sed
Dependencies for NED recompile:
Apache Ant
Bash
Gnu Sort
Gnu awk
Grep
Python3 (with packages: re, sys, getopt, subprocess, argparse, os, glob)
4. Sample device configuration
NED USAGE EXAMPLE
LDAP entries are managed under ldap-entries list
```
admin@ncs(config-config)# ?
Possible completions:
ldap-entries Expects dn input formatted with LDIF format - allowed RDNs in a combination of
(uid, cn, ou, o's and dc's) as per the device configuration;
```
/ldap-entries list has 4 keys requested to work around the unique dn name combination, as defined in ned settings too:
admin@ncs(config-config)# ldap-entries ?
Possible completions:
dn dn;; Dn value from [uid?, cn?, ou+, o+, dc?] combinations
uid Uid;; uid value to build ldif queries with
cn Common Name;; cn value to build ldif queries with
ou Organizational Unit;; ou value to build ldif queries with
o Organization;; ou value to build ldif queries with
dc Domain Component;; dc value to build ldif queries with
After the key is provided, all the attributes available will be visible:
admin@ncs(config-config)# ldap-entries dn uid=<$uid>,cn=<$cn>,ou=<$o>,o=<$o>,dc=<$dc>
Possible completions:
attributes ;; LDIF formatted attribute list
Attributes list can contain quoted LDIF ready <attribute: value> pairs, quoted if the cli doesn't otherwise accept them.
* Standard formats allowed for maximum flexibility, i.e.:
* `attributes "<attributeName>: <attributeValue>"`
* as long as it is in format:
* `attributes "<string>: <string>"`
* This way any attribute pair value can be used inside attributes list:
Which would be just fine for attribute "objectClass" or "attribute" etc, but it would probably not be okay for
"expected" unique attributes such as "password".
RedHat directory 389 allows above behavior, and since we don't have any detailed yang design to limit this behavior, it will be allowed in the NED too.
Example - see parameters objectClass, password below:
* Load a preconfigured template or insert manually all parameters and attributes as needed:
```
admin@ncs(config-config)# rload merge ../../init.cfg
Loading.
1.32 KiB parsed in 0.07 sec (17.64 KiB/sec)
```
* Show loaded config:
admin@ncs(config-ldap-entries-uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName)# commit dry-run
cli {
local-node {
data devices {
device redhat-dir389-1 {
config {
+ ldap-entries uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName {
+ attributes "attribute: ATTRIBUTE 01 VALUE";
+ attributes "attribute: ATTRIBUTE02VALUE";
+ attributes "attribute: ATTRIBUTE-03-VALUE";
+ attributes "attribute: ATTRIBUTE 04-VALUE";
+ attributes "egresspolicyname: POLICY-VALUE"
[...]
+ attributes "uid: 12345";
+ }
}
}
}
}
}
* Show prepared command to be sent to the dir389 device (dry run native - SUCCESSFUL SCENARIO) :
admin@ncs(config-ldap-entries-uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName)# commit dry-run outformat native
native {
device {
name redhat-dir389-1
data ldapadd -D "cn=Directory Manager" -w Cisco12345
dn: uid=123456,cn=abc-def.com,ou=ouName,o=orgName
objectClass: top
objectClass: cpe
uid: 123456
password: passwordValue
frameprotocol: PPP
servicetype: Framed
frameroute: 1.2.3.3/32 tag 987
frameroute: 192.123.100.0/24 distance 456 tag 321
frameroute: 66.1.111.0/24 distance 123
frameipaddress: 255.255.255.255
lsriname: abc:DEF
egresspolicyname: POLICY-NAME
ingresspolicyname: POLICY-NAME2
attribute: A02 ATT2-SECOND-VALUE
attribute: A03 frame-mode
attribute: A01 ATTRIBUTE-SECOND-VALUE
attribute: A04 -15
frameipv6route: 123:abcd:0:0:100:100:100:1/123 0::0
}
}
* Simulate command to be sent to the dir389 device (dry run native) - **FAILED SCENARIO**:
* **WARNING: exception will be thrown if NED settings are not updated accordingly. Commit will also be aborted if tried.**
i.e.:
admin@ncs(config-ldap-entries-uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName)# commit dry-run outformat native
native {
device {
name redhat-dir389-1
data Internal error in the NED NCS framework affecting device redhat-dir389-1: EXCEPTION! [123456 abc-def.com ouName orgName ] is NOT defined in ned-settings;
Please define it accordingly and retry!
}
}
TO fix above exception, update ned settings with the dn parameters, commit, run a connect/sync-from and retry.
4.4 Delete existing ldap entry
admin@ncs(config-config)# no ldap-entries dn uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName
4.5 Modify existing ldap entry - replacing existing attribute value
VERY IMPORTANT !:
To update existing attributes entry, if you wish to just replace the value of a given attribute, you must:
<1> delete existing attribute first,
<2> and then add the new attribute
* Example: update password attribute
* Enter ldap entry: `admin@ncs(config-config)# ldap-entries dn uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName`
a) Delete existing specific password attribute:
`admin@ncs(config-ldap-entries-uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName)# no attributes password:\ pass12345`
b) Create expected new password attribute:
`admin@ncs(config-ldap-entries-uid=12345,cn=abc-def.com,ou=ouName,o=oName,dc=dcName)# attributes "password: updatedPAssword"`
Issues like bugs and errors shall always be reported to the Cisco NSO NED team through
the Cisco Support channel:
The following information is required for the Cisco NSO NED team to be able
to investigate an issue:
- A detailed recipe with steps to reproduce the issue.
- A raw trace file generated when the issue is reproduced.
- SSH/TELNET access to a device where the issue can be reproduced by the Cisco NSO NED team.
This typically means both read and write permissions are required.
Pseudo access via tools like Webex, Zoom etc is not acceptable.
However, it is ok with device access through VPNs, jump servers etc though.
Do as follows to gather the necessary information needed for your device, here named 'dev-1':
Reproduce the found issue using ncs_cli or your NSO service.
Write down each necessary step in a reproduction report.
In addition to this, it helps if you can show how it should work
by manually logging into the device using SSH/TELNET and type
the relevant commands showing a successful operation.
Gather the reproduction report and a copy of the raw trace file
containing data recorded when the issue happened.
Contact the Cisco support and request to open a case. Provide the gathered files
together with access details for a device that can be used by the
Cisco NSO NED when investigating the issue.
Requests for new features and extensions of the NED are handled by the Cisco NSO NED team when
applicable. Such requests shall also go through the Cisco support channel.
The following information is required for feature requests and extensions:
Set the config on the real device including all existing dependent config
and run sync-from to show it in the trace.
Run sync-from # devices device dev-1 sync-from
Attach the raw trace to the ticket
List the config you want implemented in the same syntax as shown on the device
SSH/TELNET access to a device that can be used by the Cisco NSO NED team for testing and verification
of the new feature. This usually means that both read and write permissions are required.
Pseudo access via tools like Webex, Zoom etc is not acceptable. However, it is ok with access
through VPNs, jump servers etc as long as we can connect to the NED via SSH/TELNET.
9. How to rebuild a NED
To rebuild the NED do as follows:
> cd $NED_ROOT_DIR/src
> make clean all
When the NED has been successfully rebuilt, it is necessary to reload the package into NSO.
admin@ncs# packages reload
10. Configure the NED to use ssh multi factor authentication
This NED supports multi factor authentication (MFA) using the ssh authentication
method 'keyboard-interactive'.
Some additional steps are required to enable the MFA support:
Verify that your NSO version supports MFA. This is configurable as additional
settings in the authentication group used by the device instance.
Enter a NSO CLI and enter the following and do tab completion:
> ncs_cli -C -u admin
admin@ncs# show running-config devices authgroups group default default-map <tab>
Possible completions:
action-name The action to call when a notification is received.
callback-node Invoke a standalone action to retrieve login credentials for managed devices on the 'callback-node' instance.
mfa Settings for handling multi-factor authentication towards the device
public-key Use public-key authentication
remote-name Specify device user name
remote-password Specify the remote password
remote-secondary-password Second password for configuration
same-pass Use the local NCS password as the remote password
same-secondary-password Use the local NCS password as the remote secondary password
same-user Use the local NCS user name as the remote user name
If 'mfa' is displayed in the output like above, NSO has MFA support enabled.
In case MFA is not supported it is necessary to upgrade NSO before proceeding.
Implement the authenticator executable. The MFA feature relies on an external executable to take care of the client part
of the multi factor authentication. The NED will automatically call this executable for each challenge presented by the
ssh server and expects to get a proper response in return.
The executable can be a simple shell script or a program implemented in any programming language.
The required behaviour is like this:
read one line from stdin
The line passed from the NED will be a semi colon separated string containing the following info:
[<device name>;<user>;<password>;<opaque>;<ssh server name>;<ssh server instruction>;<ssh server prompt>;]
The elements for device name, user, password and opaque corresponds to what has been configured in NSO.
The ssh server name, instruction and prompt are given by the ssh server during the authentication step.
Each individual element in the semi colon separated list is Base64 encoded.
Extract the challenge based on the contents above.
Print a response matching the challenge to stdout and exit with code 0
In case a matching response can not be given do exit with code 2
Below is a simple example of an MFA authenticator implemented in Python3:
#!/usr/bin/env python3
import sys
import base64
# This is an example on how to implement an external multi factor authentication handler
# that will be called by the NED upon a ssh 'keyboard-interactive' authentication
# The handler is reading a line from stdin with the following expected format:
# [<device name>;<user>;<password>;<opaque>;<ssh server name>;<ssh server instruction>;<ssh server prompt>;]
# All elements are base64 encoded.
def decode(arg):
return str(base64.b64decode(arg))[2:-1]
if __name__ == '__main__':
query_challenges = {
"admin@localhost's password: ":'admin',
'Enter SMS passcode:':'secretSMScode',
'Press secret key: ':'2'
}
# read line from stdin and trim brackets
line = sys.stdin.readline().strip()[1:-1]
args = line.split(';')
prompt = decode(args[6])
if prompt in query_challenges.keys():
print(query_challenges[prompt])
exit(0)
else:
exit(2)
Configure the authentication group used by the device instance to enable MFA. There
are two configurables available:
executable The path to the external multi factor authentication executable (mandatory).
opaque Opaque data that will passed as a cookie element to the executable (optional).
> ncs_cli -C -u admin
admin@ncs# config
Entering configuration mode terminal
admin@ncs(config)# devices authgroups group <name> default-map mfa executable <path to the executable>
admin@ncs(config)# devices authgroups group <name> default-map mfa opaque <some opaque data>
admin@ncs(config)# commit
Try connecting to the device.
10.1 Trouble shooting
In case of connection problems the following steps can help for debugging: