1.使用shell的for遍历主机IP地址
1
2
3
4
5
6
|
cat
t2.sh
#!/bin/sh
for
IP
in
134 140 141 142 143 151 152 153 154 171 172 173 174 180 181 182 191 192 210 211 ;
do
.
/t1
.sh $IP
done
exit
0
|
2.使用expect发送主机密钥到所有主机
1
2
3
4
5
6
7
|
#!/usr/bin/expect
set
rip [lindex $argv 0]
spawn
ssh
-copy-
id
-i luojianlong@192.168.30.$rip
expect
"password:"
send
"pizi_luojianlong\r"
sleep
2
interact
|
3.最后执行t2.sh脚本
本文转自ljl_19880709 51CTO博客,原文链接:http://blog.51cto.com/luojianlong/1380858,如需转载请自行联系原作者