在/usr/local/bin 目录下
#!/bin/bash
user=`whoami`
passwd=000000
#yum install -y sshpass
echo "开始配置免密登录......"
for((current=102; current<=104; current++));do
for((host=102; host<=104; host++));do
sshpass -p $passwd ssh -q -o StrictHostKeyChecking=no $user@hadoop$current "sshpass -p $passwd ssh-copy-id -o StrictHostKeyChecking=no $user@hadoop$host"
done
done
echo "恭喜, 免密登录配置完成!"