江苏省吴江市双板桥路3号兴源网络

0512-63028342

ly@wjxy.net.cn

使用 sshpass批量让远程主机执行指定内容

1.建立host.list文件

cat host.list

172.11.20.1
172.11.20.2
172.11.20.3

2.安装软件包

yum install sshpass -y

3.建立do.sh

cat do.sh

read -p "请输入ssh密码: " pass for server in $(cat hostlist.txt); do sshpass -p "${pass}" ssh root@$server "ip add | grep 172.11"; done

发表回复