批量免密脚本
#!/bin/bash
echo "========马上就好,请稍后========="
yum -y install sshpass >/dev/null
ssh-keygen -f /root/.ssh/id_rsa -P ''
NET=192.168.20
export yes
export SSHPASS=123456
for IP in {12,13};do
sshpass -e ssh-copy-id $NET.$IP
if [ $? == 0 ]; then
echo '---继续执行---' >/dev/null
else
export yes
export SSHPASS=123456
fi
done
sleep 1
if [ $? == 0 ]; then
echo '---批量免密完成---'
else
echo '---请检查---'
fi
注意:用自己的IP和密码..........................