import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) def SshCheck(ip,password): global is_find is_find = False try: ssh.connect(ip, 22, 'monitor', password, timeout=1) stdin,stdout,stderr = ssh.exec_command('date') result = stdout.read() result = str(result,encoding="utf-8") if result: print('[OK]' + '\t' + ip + '\t'+ password) is_find = True except Exception as e: print(e, '\t' + ip +'\t' + password) finally: ssh.close() ipdata = open("ip.txt", "r") ip = ipdata.read().splitlines() ipdata.close() passdata = open("pwds.txt", "r") passwd = passdata.read().splitlines() passdata.close() for i in ip : for j in passwd: SshCheck(i,j) if is_find: break
标签:批量,ip,密码,ssh,linux,close,password,find,result From: https://www.cnblogs.com/xue0123/p/17025642.html