Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def connect_ssh(ip, username, password):
- #Importing paramiko and time modules for use within subroutine
- import paramiko
- import time
- remote_conn_pre=paramiko.SSHClient()
- remote_conn_pre
- remote_conn_pre.set_missing_host_key_policy(
- paramiko.AutoAddPolicy())
- #Initiates the connection to remote device
- remote_conn_pre.connect(ip, username=username, password=password, look_for_keys=False, allow_agent=False)
- #invokes shell for SSH connection
- remote_conn = remote_conn_pre.invoke_shell()
- print "Interactive SSH session established to " + ip + " with Username:" + username
- print "\nSending commands to device\n"
- sending commands to the device
- remote_conn.send("terminal monitor\n")
- remote_conn.send("terminal length 0\n")
- remote_conn.send("show snmp user \n")
- time.sleep(3)
- output = remote_conn.recv(100000)
- print "Results:" + output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement