Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys, os
- import paramiko
- import socket
- hosts_file = open("lista")
- file = open('%s.log' % sys.argv[0], 'w')
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- for server in hosts_file:
- if server == '':
- continue
- try:
- client.connect(server[:-1], 22, username="eduardomedeiros", password="fr33bsd77")
- so = os.uname()[0]
- if so == "Darwin" :
- (stdin, stdout, stderr) = client.exec_command("uname")
- saida = stdout.read()
- elif ( so = " linux
- if saida:
- print >>file, "[ %s ]: %s" % (server[:-1],saida)
- print "[ %s ]: %s" % (server[:-1],saida)
- client.close()
- print "done"
- except paramiko.AuthenticationException:
- print "Problem connecting on %s" % server
- except socket.error:
- print "Problem connecting on %s" % server
- file.close()
- sys.exit(0)
Add Comment
Please, Sign In to add comment