Guest User

Untitled

a guest
Jun 14th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. cisco-nexus(config)# username edwin password THISisWHERIAMtypingPWD<0x08>NG
  2. % Invalid command at '^' marker.
  3. cisco-nexus(config)#
  4.  
  5. username edwin password THISisWHERIAMtypingPWDNG
  6.  
  7. import paramiko
  8. import time
  9. import re
  10.  
  11. class ssh:
  12. def __init__(self, ip, user, pwd):
  13. self.ip = ip
  14. self.user = user
  15. self.pwd = pwd
  16. def device_conn(self):
  17. remote_con = paramiko.SSHClient()
  18. remote_con.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  19. remote_con.connect(hostname=self.ip, username=self.user, password=self.pwd, look_for_keys=False, allow_agent=False)
  20. remote_ses = remote_con.invoke_shell()
  21. output = remote_ses.recv(1000)
  22. time.sleep(1)
  23. remote_ses.send("conf t"+"n")
  24. time.sleep(0.5)
  25. remote_ses.send("username edwin password THISisWHERIAMtypingPWDNG"+"n")
  26. time.sleep(0.5)
  27. output = remote_ses.recv(10000)
  28. print output
  29.  
  30.  
  31. with open("device.txt","rb") as dev:
  32. for fw in dev:
  33. print fw.strip()
  34. ob = ssh(fw.strip(), "user", "pwd")
  35. output = ob.device_conn()
Add Comment
Please, Sign In to add comment