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 '