sshpass使用

 

#!/bin/bash

passwd='root'
host='10.1.1.1'
filename=$1
projectname=$2
BRANCH_NAME=$3
sshpass -p "$passwd" scp -o StrictHostKeyChecking=no "$filename" root@"$host":/opt/
sshpass -p "$passwd" ssh -o StrictHostKeyChecking=no root@"$host" "
    cd /opt
    rm -rf '$BRANCH_NAME'
    mkdir -p '$BRANCH_NAME'
    unzip -q '$filename' -d '$BRANCH_NAME'
    rm -f '$filename'
    cd '$BRANCH_NAME'/'$projectname'
    cp jenkins_script/start.sh .
    sh start.sh
"

  

posted @ 2021-12-01 16:52  香菜哥哥  阅读(215)  评论(0编辑  收藏  举报