daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top