#!/bin/bash
if [[ "$1" == '' ]];then
echo "ip error! *.sh 192.168.1.1"
exit 0
fi
echo $1
chmod +x /usr/local/test/agent
>/root/.ssh/known_hosts
sshpass -p Run@Root!@ ssh root@$1 -o StrictHostKeyChecking=no "systemctl stop wgAgent"
sshpass -p Run@Root!@ scp -o StrictHostKeyChecking=no /usr/local/test/agent root@$1:/usr/local/test/
sshpass -p Run@Root!@ ssh root@$1 -o StrictHostKeyChecking=no "systemctl start agent"
sshpass -p Run@Root!@ ssh root@$1 -o StrictHostKeyChecking=no "sleep 2 & systemctl status agent"
echo 'success'
标签:Run,sshpass,no,ssh,key,StrictHostKeyChecking,root,public
From: https://www.cnblogs.com/guowenrui/p/17022875.html