#1
|
|||
|
|||
![]()
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() |
#2
|
|||
|
|||
Hi arortizg,
The ConnectInTab() method takes an optional parameter which determines whether the call fails silently or raises an exception: And then a relevant line of info from Connect() method:
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Hi arortizg,
Also, you will likely need to enable the Display logon prompts in terminal window option in the Connection / Logon Actions category of Session Options. You would make that change to Default session since you are making ad hoc connections in your script.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Tags |
failed , multiple log , python , ssh2 |
Thread Tools | |
Display Modes | Rate This Thread |
|
|