Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import paramiko
  2. def open_ssh_conn(ip):
  3. try:
  4. #Logging into device
  5.  
  6. session = paramiko.SSHClient()
  7.  
  8.  
  9.  
  10. session.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  11.  
  12.  
  13.  
  14. session.connect(ip, username = "username", password = "password")
  15.  
  16.  
  17.  
  18. connection = session.invoke_shell()
  19.  
  20. except paramiko.AuthenticationException:
  21.  
  22. print "* Invalid username or password!"
  23.  
  24. print "* Closing program...n"
  25.  
  26. #Calling the SSH function
  27. open_ssh_conn("192.168.100.1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement