Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. ssh = SSHConfig()
  2. params = ssh.lookup(user_password_rnm)
  3. ssh = SSHClient()
  4. ssh.set_missing_host_key_policy(AutoAddPolicy())
  5. ssh.connect(ipAddress_rnm, port=22, username=user_name_rnm,
  6. password=user_password_rnm)
  7. if ssh.invoke_shell():
  8. st = ['with: ', name_rnm, ' - OK']
  9. showinfo('Connection', ' '.join(st))
  10. ssh.close()
  11. else:
  12. st = ['with: ', name_rnm, ' - NO CONNECT']
  13. showinfo('Connection', ' '.join(st))
  14.  
  15. try:
  16. ssh.connect(ipAddress_rnm, port=22, username=user_name_rnm, password=user_password_rnm)
  17. ssh.invoke_shell()
  18. st = 'with: {0} - OK'.format(name_rnm)
  19. showinfo('Connection', st)
  20. ssh.close()
  21. except (BadHostKeyException, AuthenticationException, SSHException) as e:
  22. st = 'with: {0} - NO CONNECT. Reason: {1}'.format(name_rnm, str(e))
  23. showinfo('Connection', st)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement