shell
# 批量安装sshpass.
# -o StrictHostKeyChecking=no 跳过ssh首次连接时需要输入yes
for ip in 172.16.116.{188..191}; do
sshpass -pwww.39doo.com ssh -o StrictHostKeyChecking=no root@$ip 'yum install sshpass -y';
done
批量执行本地脚本
shell
for ip in 172.16.116.{188..191}; do
sshpass -pwww.39doo.com ssh -o StrictHostKeyChecking=no root@$ip < ./hosts.sh;
done
批量执行远程脚本
shell
for ip in 172.16.116.{188..191}; do
sshpass -pwww.39doo.com ssh -o StrictHostKeyChecking=no root@$ip "./hosts.sh";
done