#!/bin/bash set +x base_dir=$(pwd) ip_list='10.200.7.28,10.200.7.29,10.200.7.30,10.200.7.31' USER='root' PWD='123456' INSTALL() { echo "開始導入public-key" sleep 1s for IP in `echo "${ip_list}"|awk -F, 'BEGIN{OFS=" "}{$1=$1;printf("%s",$0);}'` do sshpass -p ${PWD} ssh-copy-id -o StrictHostKeyChecking=no ${USER}@${IP} echo "${IP}服務器完成" done } INSTALL