安装sshpass
yum install sshpass -y
host.txt
ip,root密码 一下示例
111.111.111.111,admin@1234
free -h 这里引号内写命令
for ip in cat host.txt
;do echo $ip | awk -F"," '{print $1}';sshpass -p echo $ip | awk -F"," '{print $2}'
ssh -o StrictHostKeyChecking=no root@$(echo $ip | awk -F"," '{print $1}') "free -h";done