Automation

 View Only
last person joined: 7 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  PyEz ConnectAuthError

    Posted 08-09-2022 09:46
    This one has me scratching my head....

    Trying to connect to an EX-3400 using PyEz. I've done 'set system services netconf ssh'. I can connect fine using ncclient but PyEz gives me "ConnectAuthError". Here's my code:

    import sys
    from getpass import getpass
    from jnpr.junos import Device
    from jnpr.junos.exception import ConnectError
    
    hostname = input("Device hostname: ")
    junos_username = input("Junos OS username: ")
    junos_password = getpass("Junos OS or SSH key password: ")
    
    dev = Device(host=hostname, user=junos_username, passwd=junos_password)
    
    try:
        dev.open()
    except ConnectError as err:
        print ("Cannot connect to device: {0}".format(err))
        sys.exit(1)
    except Exception as err:
        print (err)
        sys.exit(1)
    
    
    print (dev.facts)
    dev.close()​

    I don't understand how ncclient works but not PyEz since they both use netconf. I've tried using the root user as well as a 'pyez' user that has read-only rights. Any help would be greatly appreciated.



  • 2.  RE: PyEz ConnectAuthError

     
    Posted 08-09-2022 10:21
    Hi Joseph.

     'set system services netconf ssh' opens up port 22 for netconf connections, whereas I believe PyEZ tries to log into port 830 by default. Try specifying port 22 when creating your Device() object.

    --Deepak