|
#1
|
|||
|
|||
try different passwords
I have this script that works great to do different things
but lately there were some hosts that have old passwords .,. pass2 and pas3 I trying to add a simple way for it to try pass2 and pass3 if needed until it gets to crt.Screen.WaitForString("]# ") any advice / help is welcome. Code:
# $language = "python" # $interface = "1.0" def main(): crt.Screen.Synchronous = False with open('/hosts') as hosts_: for host in hosts_: crt.Screen.WaitForString("working # ") crt.Screen.Send("ssh -oStrictHostKeyChecking=no root@" + host + '\r') crt.Screen.WaitForString("word: ") crt.Screen.Send("pass1" + chr(13)) crt.Screen.WaitForString("]# ") crt.Screen.Send("uname -a;df -h" + chr(13)) crt.Screen.WaitForString("]# ") crt.Screen.Send("exit" + chr(13)) main() |
#2
|
|||
|
|||
Hi rleon,
We do not have a script example that shows exactly how to accomplish this. You may be able to modify our "Jump Host - Handle Secondary Host Connection Attempts" script to try more than one password for each host. Please refer to the following link: https://forums.vandyke.com/showpost....62&postcount=1 If time and resources becomes available we might be able to provide a specific example as to how you could accomplish this. We will be sure to post the example here if that is the case. Have a great day!
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Thank you i tried that
I replaced With my promit Code:
strJumpHostPrompt = "# " Code:
ScriptError Error: Connection lost File: /Users/rleon/crt_scripts/nfs2/test2.py Line: 44 crt.Screen.WaitForString(strCommand + "\r\n") If i can get this work it would be great .. but the only thing is i have 100's of hosts Reading from a list would make this script ideal. Code:
with open('/Users/rleon/hosts') as hosts_: for host in hosts_: |
#4
|
|||
|
|||
I took the script and stripped out some stuff made sure the indents were ok.
when i run it .. it doesnt fall into any of the if statements Any help would be appreciated. ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test ssh root@test root@test's password: Permission denied, please try again. root@test's password: Code:
# $language = "python" # $interface = "1.0" import SecureCRT crt.Screen.Synchronous = True def main(): vHosts = [\ "test", "test2", "test3", "test4"] vPossibleResponses = [\ "]# ", "ogin:", "(yes/no)?", "sword: ", "timed out"] nIndex = 0 strJumpHostPrompt = "# " while nIndex <= len(vHosts): strCommand = "ssh root@" + vHosts[nIndex] crt.Screen.Send(strCommand + "\r") crt.Screen.WaitForString(strCommand + "\r\n") while True: crt.Screen.WaitForStrings(vPossibleResponses) if crt.Screen.MatchIndex > 0: strStringFound = vPossibleResponses[crt.Screen.MatchIndex - 1] if crt.Screen.MatchIndex == 1: crt.Screen.Send("uname -a" + chr(13)) crt.Screen.WaitForString("]# ") crt.Screen.Send("exit" + chr(13)) crt.Screen.WaitForString(strJumpHostPrompt) break elif crt.Screen.MatchIndex == 2: crt.Screen.Send("rleon16" + chr(13)) elif crt.Screen.MatchIndex == 3: crt.Screen.Send("yes\r") elif crt.Screen.MatchIndex == 4: crt.Screen.Send("SomePass" + chr(13)) elif crt.Screen.MatchIndex == 5: crt.Screen.WaitForString(strJumpHostPrompt) break else: crt.Dialog.MessageBox("Yikes!\r\n\r\n" "We never expect to get here.\r\n" "\t" + strStringFound) crt.Screen.SendSpecial("MENU_SCRIPT_CANCEL") nIndex = nIndex + 1 main() |
#5
|
|||
|
|||
Hi rleon,
You have entered an infinite while loop, resulting in your SSH command being sent repeatedly. We have modified the script example that I mentioned in my previous response to iterate over multiple usernames and passwords. Please re-download and test with the modified script example: https://forums.vandyke.com/showpost....62&postcount=1 Please let me know if you have any specific questions regarding the modified script.
__________________
Thanks, --Brittney VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|