centos6.6 批量分發腳本
#!/bin/bash
#chuangjian,key pair
rm -f /root/.ssh/id_dsa*
ssh-keygen -t dsa -f /root/.ssh/id_dsa -P "" -q
#install sshpass
yum install sshpass -y &>/dev/null
# fenfa key file
for ip in `cat /server/scripts/game_ip.txt`
do
echo "===== fenfa key to host $ip ====="
sshpass -proot密碼 ssh-copy-id -i /root/.ssh/id_dsa.pub "-o StrictHostkeyChecking=no root@$ip" #centos7 root@ip 放到雙引号外面
echo "============= fenfa end =================="
echo ""
done
批量檢查腳本
#!/bin/bash
CMD="$1"
if [ $# -ge 1 ];then
for ip in ·cat game_ip.txt·
do
echo "====== host $ip info ========"
ssh $ip $CMD
echo "======================================"
echo ""
done
else
exit
fi