python 批量修改root密码
#_*_coding:utf8_*_ from multiprocessing import Process, Pool import paramiko import sys,os host_list = ( ('192.168.1.91', 'root','654321',123456), ('192.168.1.93', 'root', '654321',123456), ) s = paramiko.SSHClient() #绑定实例 s.load_system_host_keys() #加载本机HOST主机文件 s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) def ssh_run(host_info): ip,username,password,newpassword = host_info s.connect(ip,22,username,password,timeout=5) #连接远程主机 stdin,stdout,stderr=s.exec_command('echo %s | passwd --stdin root'%(newpassword)) #stdin,stdout,stderr=s.exec_command('df') cmd_result = stdout.read(),stderr.read() #读取命令结果 print '