0
点赞
收藏
分享

微信扫一扫

SSH远程执行脚本


SSH远程执行命令参考

#!/bin/bash

#变量定义
ip_array=("192.168.1.1" "192.168.1.2" "192.168.1.3")
user="test1"
remote_cmd="/home/test/1.sh"

#本地通过ssh执行远程服务器的脚本
for ip in ${ip_array[*]}
do
if [ $ip = "192.168.1.1" ]; then
port="7777"
else
port="22"
fi
ssh -t -p $port $user@$ip "remote_cmd"



举报

相关推荐

0 条评论