Guest User

Untitled

a guest
Jan 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. for server in servers:
  2.     ssh = paramiko.SSHClient()
  3.     ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  4.     try:
  5.         ssh.connect(server, **ssh_auth)
  6.     except paramiko.AuthenticationException:
  7.         print "Authentication Failed for",server
  8.    
  9.     sftp = ssh.open_sftp()
  10.    
  11.     ldap_conf_lines = sftp.open('/etc/ldap.conf').readlines()
  12.     ssh.close()
  13.     ldap_conf_data = parse_ldap_conf(ldap_conf_lines)
  14.     report_file.write('hostname: %s, bind_timelimit: %s, timelimit: %s, AAA Auth: %s\n' %
  15.                       (server,
  16.                        ldap_conf_data.get('bind_timelimit'), # or ldap_conf_data.get('#bind_timelimit'),
  17.                        ldap_conf_data.get('timelimit'), # or ldap_conf_data.get('#timelimit'),
  18.                        ldap_conf_data.get('host') or ldap_conf_data.get('uri'),
  19.                       ))
Add Comment
Please, Sign In to add comment