ssh模仿ansible批量执行命令的功能

#!/bin/bash
ssh_hosts=("IP" "IP1".......)
user=root
remote_cmd="df -h"
port=22
for ip in ${ssh_hosts[*]}
do

    ssh -t $user@$ip $remote_cmd

done

其中remote_cmd改成你想执行的命令,其中控制机和被执行命令的机器做了免秘钥登录

posted @ 2016-12-20 11:42  梦轻尘  阅读(506)  评论(0编辑  收藏  举报