Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-20-2021, 11:46 AM
arortizg arortizg is offline
Registered User
 
Join Date: Mar 2021
Posts: 1
Unhappy Re-attempt SSH login.

Hello Forum.


Hope all of you are doing fine.


I'm having this problem which I'm sure you have already encountered and fix, but I haven't been able to find an answer yet in the forum.


I'm using this script to logging into multiple devices through SSH2. The problems relies when the first Username and Password fail, then I attempt to use a second Username and Password but the programs seems to never reach that part of the code because a Error window pops saying "Keyboard-Interactive authentication with the SSH2 server failed" and wont let the "else" to execute, any idea on how to make the program try another set of username and password if the the first one failed?


Code:
# $language = "python"
# $interface = "1.0"

# This script demonstrates how to open a text file and read it line by
# line to a server.

# CopyToClipboard.py


devices = ["10.238.10.10",
"10.238.10.11",
"10.238.10.12"
]


def mainConnection():

    for dev in devices:

        try:
            crt.Session.ConnectInTab("/SSH2 /L USERNAME1 /PASSWORD PASSWORD1 " + dev)
        except ScriptError:
            error = crt.GetLastErrorMessage()

        if crt.Session.Connected == True:
            crt.Dialog.MessageBox("Connection successful " )
        else:
            ###This is the line of code that wont execute if the first username and pass fail.
            crt.Session.ConnectInTab("/SSH2 /L USERNAME2 /PASSWORD PASSWORD2 " + dev)



def main():
    mainConnection()
    #sendingCommand()


        


main()
Reply With Quote
 

Tags
failed , multiple log , python , ssh2

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 02:55 PM.