Guest User

Untitled

a guest
Feb 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 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. client = paramiko.SSHClient()
  10. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  11.  
  12. for server in hosts_file:
  13. if server == '':
  14. continue
  15.  
  16. try:
  17. client.connect(server[:-1], 22, username="eduardomedeiros", password="fr33bsd77")
  18. so = os.uname()[0]
  19. if so == "Darwin" :
  20. (stdin, stdout, stderr) = client.exec_command("uname")
  21. saida = stdout.read()
  22. elif ( so = " linux
  23.  
  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