Giter Site home page Giter Site logo

Comments (2)

3fr61n avatar 3fr61n commented on May 31, 2024

Hi

I reproduced your issue and the fix is to use a 'absolute' path to where rsa key is located, because cron script execute the open-nti from '/' instead of /opt/open-nti/ directory

`

1.- Enter to the container where netconf collector resides (the location may vary depending on open-nti version)

juniper@naraku:~/scripts/open-nti$ make cli   
docker exec -i -t opennti_con /bin/bash

root@b0e5b5da0a42:~# cd /opt/open-nti/data/
root@b0e5b5da0a42:/opt/open-nti/data# ls
commands.yaml  credentials.yaml  hosts.yaml  junos_parsers  open-nti.variables.yaml  pfe_parsers
root@b0e5b5da0a42:/opt/open-nti/data# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /opt/open-nti/data/id_rsa_dc
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /opt/open-nti/data/id_rsa_dc.
Your public key has been saved in /opt/open-nti/data/id_rsa_dc.pub.
The key fingerprint is:
ed:d9:17:d6:ce:56:8e:23:fd:16:e5:5a:c0:45:27:bd root@b0e5b5da0a42
The key's randomart image is:
+--[ RSA 2048]----+
|              .oo|
|               .+|
|             . ..|
|         .    oE.|
|        S .   oo+|
|         . o o B+|
|          o o =o*|
|             o.+.|
|               ..|
+-----------------+
root@b0e5b5da0a42:/opt/open-nti/data# ls
commands.yaml  credentials.yaml  hosts.yaml  id_rsa_dc  id_rsa_dc.pub  junos_parsers  open-nti.variables.yaml  pfe_parsers
root@b0e5b5da0a42:/opt/open-nti/data# ls -la
total 40
drwxrwxr-x 4 1000 1000 4096 Feb  6 17:46 .
drwxr-xr-x 4 root root 4096 Feb  2 18:32 ..
-rw-rw-r-- 1 1000 1000  770 Feb  2 12:41 commands.yaml
-rw-rw-r-- 1 1000 1000  106 Feb  2 12:41 credentials.yaml
-rw-rw-r-- 1 1000 1000   11 Feb  2 12:41 hosts.yaml
-rw------- 1 root root 1679 Feb  6 17:46 id_rsa_dc
-rw-r--r-- 1 root root  399 Feb  6 17:46 id_rsa_dc.pub
drwxrwxr-x 2 1000 1000 4096 Feb  2 12:41 junos_parsers
-rw-rw-r-- 1 1000 1000  736 Feb  2 12:41 open-nti.variables.yaml
drwxrwxr-x 2 1000 1000 4096 Feb  2 12:41 pfe_parsers
root@b0e5b5da0a42:/opt/open-nti/data# scp ./id_rsa_dc.pub [email protected]:/var/tmp
The authenticity of host '192.168.89.101 (192.168.89.101)' can't be established.
ECDSA key fingerprint is 1c:87:73:82:0d:38:44:7b:09:2b:e2:ff:00:cb:98:d8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.89.101' (ECDSA) to the list of known hosts.
Password:
id_rsa_dc.pub                                                                                                              100%  399     0.4KB/s   00:00    
root@b0e5b5da0a42:/opt/open-nti/data# 


2.- Meanwhile on the junos router

test@R1> configure private 

[edit]
root@R1# set system login user test authentication load-key-file /var/tmp/id_rsa_dc.pub 

[edit]
root@R1# commit and-quit 
commit complete
Exiting configuration mode

root@R1> 

3.- Then test the ssh connection

root@b0e5b5da0a42:/opt/open-nti/data# 
root@b0e5b5da0a42:/opt/open-nti/data# 
root@b0e5b5da0a42:/opt/open-nti/data# ssh -i id_rsa_dc [email protected]
--- JUNOS 15.1F6.9 built 2016-07-01 13:06:43 UTC
test@R1> exit 



4.- Now through open-nti/pyez


root@b0e5b5da0a42:/opt/open-nti/data# cat hosts.yaml 
192.168.89.101: test
root@b0e5b5da0a42:/opt/open-nti/data# cat credentials.yaml 
test_credentials:
    username: test 
    password: 
    method: key 
    key_file: /opt/open-nti/data/id_rsa_dc  <--- Absolute path
    tags: test
root@b0e5b5da0a42:/opt/open-nti/data# 

root@b0e5b5da0a42:/opt/open-nti/data# cat commands.yaml 
# GENERIC COMMANDS

#NOTE:  Commands will be executed & parsed as text/regex ONLY if there isn't any valid xml output for that command
#       (so please check the output of the command with "| display xml" before building the parser or adding it in this file)

lab_commands:
   commands: |
      show route summary | display xml
   tags: test

# Do not remove this three dashes (“---”) they are used to separate documents
---


5.- Exit container and test

juniper@naraku:~/scripts/open-nti$ make cron-debug
docker exec -i -t opennti_con /usr/bin/python /opt/open-nti/open-nti.py -s -c
Collector Thread-1 scheduled with following hosts: ['192.168.89.101']
Connecting to host: 192.168.89.101
[192.168.89.101]: Executing command: show version | display xml
[192.168.89.101]: Host will now be referenced as : R1
[R1]: Executing command: show route summary | display xml
[R1]: Parser found and processed, going to next comand.
[R1]: timestamp_tracking - CLI collection 4
Inserting into database the following datapoints:
[{'fields': {'delta_str': 'N/A', 'value_str': 'vmx'},
  'measurement': 'base-info',
  'tags': {'device': 'R1',
           'kpi': 'base-info',
           'product-model': 'vmx',
           'version': '15.1F6.9'}},
 {'fields': {'delta': 4, 'value': 4},
  'measurement': 'open-nti-stats',
  'tags': {'device': 'R1',
           'kpi': 'open-nti-stats',
           'product-model': 'vmx',
           'stats': 'collection-time',
           'version': '15.1F6.9'}},
 {'fields': {'delta': 1, 'value': 1},
  'measurement': 'open-nti-stats',
  'tags': {'device': 'R1',
           'kpi': 'open-nti-stats',
           'product-model': 'vmx',
           'stats': 'collection-successful',
           'version': '15.1F6.9'}}]
[R1]: timestamp_tracking - total collection 4

`

from open-nti.

mziegler8888 avatar mziegler8888 commented on May 31, 2024

from open-nti.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.