View Single Post
  #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