首页 > 系统相关 >Linux远程命令+传输文件+清除ssh public key

Linux远程命令+传输文件+清除ssh public key

时间:2023-01-03 17:22:33浏览次数:41  
标签:Run sshpass no ssh key StrictHostKeyChecking root public

#!/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

相关文章