该脚本的前提是在 ~/.ssh/config 已经配置好的情况下使用

#!/bin/bash
#####################################################################
########    服务器批量操作脚本
########    Email: i@liufang.org.cn
#####################################################################
for host in `cat ~/.ssh/config |grep 'Host '|awk -F ' ' '{print $2}'`
do
	echo -e "\033[34m\r\nexec command:$1 at host $host \033[0m"
	ssh $host $@
done

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注