批量修改多台主机的root密码为随机密码
[root@centos7 script]#cat change_root_pass.sh
#!/bin/bash
#
#********************************************************************
#Author: zhangxiurong
#QQ: 1257642534
#Date: 2020-02-06
#FileName: change_root_pass.sh
#Description: The test script
#Copyright (C): 2020 All rights reserved
#********************************************************************
rpm -q sshpass &>/dev/null ||yum install sshpass -y
export SSHPASS=123456
NET=192.168.70
for i in {1..254};do
{
PASS=`openssl rand -base64 9`
sshpass -e ssh $NET.$i "echo $PASS |passwd --stdin root &> /dev/null"
echo $NET.$i:$PASS >> /data/pass.txt
}&
done
wait