Devnet
NSO
Adding Devices from Eve Ng
# Configuring Devices in Cisco NSO
 
This document provides a step-by-step guide on how to configure devices in Cisco NSO (Network Services Orchestrator), including adding devices, setting up authentication, and enabling the enable password.
 
## Step 1: Prepare EVE-NG Lab
 
Ensure that your EVE-NG lab is set up correctly with the devices you want to manage using Cisco NSO. Make sure all devices are reachable and properly configured in the EVE-NG lab environment.
 
## Step 2: Install and Configure Cisco NSO
 
Download Cisco NSO from the official Cisco website and follow the installation instructions provided in the documentation. Ensure that NSO is installed and running correctly on your Ubuntu system.
 
## Step 3: Configure NSO to Manage Devices
 
### Edit ncs.conf File
 
1. Locate the `ncs.conf` file within the NSO installation directory (typically found at `/opt/ncs/`).
2. Open `ncs.conf` in a text editor such as `vim` or `nano`.
 
### Encrypt Passwords
 
Use the following Python script to generate encrypted passwords for use in the NSO configuration. If `ncs-crypt` and other encryption methods do not work, you can use this Python script as an alternative:
 
```python
import bcrypt
 
def encrypt_password(password):
    # Generate salt and hash the password
    salt = bcrypt.gensalt()
    hashed_password = bcrypt.hashpw(password.encode(), salt)
    return hashed_password.decode()
 
if __name__ == "__main__":
    # Input the password to be encrypted
    password = input("Enter the password to encrypt: ")
    
    # Encrypt the password
    encrypted_password = encrypt_password(password)
    
    # Output the encrypted password
    print("Encrypted password:", encrypted_password)

Save this script to a file, for example, encrypt_password.py, and run it:

python encrypt_password.py

Enter the password you want to encrypt when prompted, and the script will output the encrypted version of the password.

Update Device Configurations

Update the ncs.conf file with the following device configurations:

<!-- EVE-NG Lab -->
<authgroups>
    <authgroup>
        <name>eve-ng</name>
        <default-map>
            <name>default</name>
            <username>admin</username>
            <secret>$2b$12$66lugZ3IyXOHvaeCKhtl2.r4kq0CyxsmJCRV5wUJzO1EEoIVmqXcO</secret> <!-- Encrypted password -->
        </default-map>
    </authgroup>
</authgroups>
 
<devices>
    <device>
        <name>ios-xe</name>
        <address>192.168.1.151</address>
        <port>22</port>
        <authgroup>eve-ng</authgroup>
        <device-type>cli</device-type>
        <description>EVE-NG CSR1</description>
        <enable-password>$2b$12$66lugZ3IyXOHvaeCKhtl2.r4kq0CyxsmJCRV5wUJzO1EEoIVmqXcO</enable-password> <!-- Encrypted enable password -->
    </device>
    <device>
        <name>ios-xe</name>
        <address>192.168.1.152</address>
        <port>22</port>
        <authgroup>eve-ng</authgroup>
        <device-type>cli</device-type>
        <description>EVE-NG CSR2</description>
        <enable-password>$2b$12$66lugZ3IyXOHvaeCKhtl2.r4kq0CyxsmJCRV5wUJzO1EEoIVmqXcO</enable-password> <!-- Encrypted enable password -->
    </device>
    <device>
        <name>ios-xe</name>
        <address>192.168.1.153</address>
        <port>22</port>
        <authgroup>eve-ng</authgroup>
        <device-type>cli</device-type>
        <description>EVE-NG CSR3</description>
        <enable-password>$2b$12$66lugZ3IyXOHvaeCKhtl2.r4kq0CyxsmJCRV5wUJzO1EEoIVmqXcO</enable-password> <!-- Encrypted enable password -->
    </device>
</devices>

Replace placeholders with actual details and encrypted passwords.

Reload NSO Configuration

After updating ncs.conf, reload the NSO configuration to apply the changes.

$ ncs_cli -u admin
admin@ncs# packages reload

Step 4: Verify Configuration

Verify that NSO recognizes the devices you've added by checking the device inventory.

$ ncs_cli -u admin
admin@ncs# show devices list

Ensure that the devices you added are listed and their details are correct.

By following these steps, you should be able to successfully configure devices in Cisco NSO and manage them effectively.