#!/bin/bash
rpm -q sshpass &> /dev/null || yum -y install sshpass
export SSHPASS=1
NET=10.0.0
for i in {1..7};do
{
PASS=`openssl rand -base64 9`
sshpass -e ssh -o StrictHostKeyChecking=no $NET.$i "echo $PASS|passwd --stdin root &> /dev/null
echo $NET.$i:$PASS >> host.txt
}&
done
wait
export SSHPASS=1
sshpass -e ssh -o StrictHostkeyChecking=no 10.0.0.7
ENV=`openssl rand -base64 9`
echo $ENV |passwd --stdin root
echo $ENV >> HOST.TXT
标签:ENV,echo,sshpass,PASS,NET,password,root,change
From: https://www.cnblogs.com/zikang/p/17103942.html