Automation

 View Only
last person joined: 2 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.

Getting paramiko SSH authentication error while trying to StartShell in PyEZ when connected to device via a console server, works fine through the management IP network

  • 1.  Getting paramiko SSH authentication error while trying to StartShell in PyEZ when connected to device via a console server, works fine through the management IP network

    Posted 03-07-2018 07:39

    I am attempting to run some scripts on an NFX250 through a serial connection. I need to use the StartShell module (which internally uses paramiko) as I want to make changes to some files from the shell which cannot be directly accessed by the CLI. 

     

     

    from jnpr.junos import Device
    from jnpr.junos.utils.start_shell import StartShell
    
    dev = Device(host='10.10.10.11',port="7018",mode="telnet", user='root', password='xyz')
    dev.open()
    
    with StartShell(dev) as ss:
    
            ret, got=ss.run('cli')
            print(got+"\n")
    dev.close()

    I am getting the following error message

     

     

    root@dc71:~/ztp_dir# python final_ztp.py 
    Traceback (most recent call last):
      File "final_ztp.py", line 6, in <module>
        with StartShell(dev) as ss:
      File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/start_shell.py", line 162, in __enter__
        self.open()
      File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/start_shell.py", line 93, in open
        password=junos._auth_password,
      File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 424, in connect
        passphrase,
      File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 714, in _auth
        raise saved_exception
    paramiko.ssh_exception.BadAuthenticationType: ('Bad authentication type', [u'publickey', u'keyboard-interactive']) (allowed_types=[u'publickey', u'keyboard-interactive'])

     When I tried running the script manually using the python shell, I got the error while opening the StartShell connection.

     

    >>> 
    >>> from jnpr.junos import Device
    >>> from jnpr.junos.utils.start_shell import StartShell
    >>> dev = Device(host='10.10.10.11',port="7018",mode="telnet", user='root', password='xyz')
    >>> dev.open()
    Device(10.10.10.11)
    >>> ss=StartShell(dev)
    >>> ss.open()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/start_shell.py", line 93, in open
        password=junos._auth_password,
      File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 424, in connect
        passphrase,
      File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 714, in _auth
        raise saved_exception
    paramiko.ssh_exception.BadAuthenticationType: ('Bad authentication type', [u'publickey', u'keyboard-interactive']) (allowed_types=[u'publickey', u'keyboard-interactive'])
    >>> 

    This is not exclusive to NFX250 and I am facing the same issue with an EX2200 as well. The error states "BadAuthenticationType" but the same script works fine if I run it on the management IP instead of the telnet console server, with the same username and password. Need to make changes to a recently zeroized device (hence using console connection).

     

    I would be grateful if anyone can help me troubleshoot this. Thank you.


    #console
    #pyez
    #serial
    #paramiko