Guest User

Untitled

a guest
Feb 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import sys, os
  4. import paramiko
  5. import socket
  6. hosts_file = open("lista")
  7. file = open('%s.log' % sys.argv[0], 'w')
  8.  
  9.  
  10. client = paramiko.SSHClient()
  11. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  12.  
  13. for server in hosts_file:
  14. if server == '':
  15. continue
  16.  
  17. try:
  18. client.connect(server[:-1], 22, username="eduardomedeiros", password="fr33bsd77")
  19. so = os.uname()[0]
  20. print so
  21. (stdin, stdout, stderr) = client.exec_command("uname -a")
  22.  
  23. saida = stdout.read()
  24.  
  25. if saida:
  26. print >>file, "[ %s ]: %s" % (server[:-1],saida)
  27. print "[ %s ]: %s" % (server[:-1],saida)
  28.  
  29.  
  30. client.close()
  31. print "done"
  32.  
  33. except paramiko.AuthenticationException:
  34. print "Problem connecting on %s" % server
  35.  
  36. except socket.error:
  37. print "Problem connecting on %s" % server
  38.  
  39.  
  40. file.close()
  41. sys.exit(0)
Add Comment
Please, Sign In to add comment