机器之间已经加了互信,不知道互信的可以自行百度
[root@CdsTestServer tmp]# cat iplist.txt
root 192.168.3.24 /tmp/
root 192.168.3.34 /tmp/
[root@CdsTestServer tmp]# cat common-config.sh
#!/bin/bash
file=/tmp/iplist.txt
cat $file | while read line
do
username=`echo $line | awk '{print $1}'`
ip=`echo $line | awk '{print $2}'`
path=`echo $line | awk '{print $3}'`
echo $username
echo $ip
echo $path
scp /tmp/test.txt $username@$ip:$path m
done < $file
[root@CdsTestServer tmp]# sh +x common-config.sh
root
192.168.3.24
/tmp/
test.txt 100% 16 0.0KB/s 00:00
root
192.168.3.34
/tmp/
test.txt 100% 16 0.0KB/s 00:00
[root@CdsTestServer tmp]#