Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SSH connections
#3
Sorry you are right, I forgot to put my code:

I tried this code an sometimes is working and you can get the result, but sometimes is not working, I can't understand how it is working sometimes and others not, I was playing with the clear buffers and timeouts and its appears to be affected to all the execution.
I don't knwo if this type of code is correct or not to jump from one device to another "both router cisco" in this case.

Thanks for your help.


jumpserver = {'device_type' : 'cisco_ios','ip' : ipNoc,'username':userNoc,'password' : passNoc}

for x in range(1,len(first_column)-1):
host=first_column[x].value
print("")
print (" SSH Session Established with " + ipNoc + " ....")
net_connect = ConnectHandler(**jumpserver)
print("")
print (" Interactive Session Established with " + ipNoc + " ....")
print ("")
net_connect.clear_buffer()
output=net_connect.find_prompt()
print("Trying to connecting from " + output + " to " + host +".test.net")
net_connect.clear_buffer()
net_connect.settimeout(None)
net_connect.write_channel("ssh -l "+ userAtt + " " + host +".test.net")
print("")
print (" SSH Session Established with " + host + " ....")
time.sleep(4)
net_connect.send_command('password' + "\n")
print("")
print (" Interactive Session Established with " + host + " ....")
print ("")
net_connect.clear_buffer()
net_connect.read_channel()
redispatch(net_connect, device_type='cisco_ios')
output=net_connect.find_prompt()
print(output)
output=net_connect.send_command('sh ver')
print(output)
time.sleep(timeout_modifier)
Reply


Messages In This Thread
SSH connections - by Will - Jun-18-2017, 06:11 AM
RE: SSH connections - by sparkz_alot - Jun-18-2017, 12:20 PM
RE: SSH connections - by Will - Jun-19-2017, 04:08 AM
RE: SSH connections - by sparkz_alot - Jun-19-2017, 12:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I make this server stop listening for connections to sockets Emekadavid 0 3,486 Jun-03-2020, 02:28 PM
Last Post: Emekadavid
  Need small help on dynamic database connections Tirumal 4 3,502 Dec-28-2017, 07:02 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020