有这样一个要求,有N台服务器,每台服务器的端口都不一样
比如 1.1.1.1:22;
2.2.2.2:33;
3.3.3.3:55;
……
所有服务器都做成免密登录
首先写一个文件把ip和对应的端口写入 比如: vim scp.log 1.1.1.1:22 2.2.2.2:33 3.3.3.3:55 …… vim scp.sh #!/bin/bash #author:limingyu (Email:[email protected]) #this is a scp.sh while read line do for i in $line do touch /tmp/scp.txt echo $i > /tmp/scp.txt scp /tmp/a.txt -P `awk -F: ‘{print $NF}‘ /tmp/scp.txt` [email protected]`awk -F: ‘{print $1}‘ /tmp/sc p.txt`:/tmp/ echo > /tmp/scp.txt done done < /tmp/scp.log
时间: 2024-10-07 12:58:37