shell编程怎么输入参数
发布网友
发布时间:2022-04-21 12:07
我来回答
共1个回答
热心网友
时间:2023-11-01 16:43
1、安装sshpass或设置ssh无密码访问
tar zxf sshpass-1.05.tar.gz
cd sshpass-1.05
./configure;make;make install
which sshpass
/usr/local/bin/sshpass
2、创建文件ip.txt
192.168.1.101 111111
192.168.1.102 111112
192.168.1.103 111113
192.168.1.104 111114
192.168.1.105 111115
192.168.1.106 111116
3、remote-reboot.sh
#!/bin/sh
while read ip pw;
do
sshpass -p "$pw" ssh root@$ip "reboot";
done < ip.txt