ssh 批量执行命令
#版本1 #!/bin/bash while read line do Ip=`echo $line|awk '{print $1}'` Passwd=`echo $line|awk '{print $2}'` ssh -n localhost "cat -" sshpass -p "$Passwd" ssh -n -t -o StrictHostKeyChecking=no root@$Ip "id" done<iplist.txt
#版本2 #!/bin/bash Iplist=`awk '{print $1}' iplist.txt` for Ip in $Iplist do Passwd=`awk '/'$Ip'/{print $2}' iplist.txt` sshpass -p "$Passwd" ssh -n -t -o StrictHostKeyChecking=no root@$Ip "id" done