Created
March 31, 2017 12:59
-
-
Save appleshan/812e2ae4077af8d9eb64beaa3411321c to your computer and use it in GitHub Desktop.
ssh upload script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function run_script() { | |
ssh -i ${SSH_CERT} -p 22 ${REMOTE_USER}@${REMOTE_HOST} "$@" | |
return $? | |
} | |
function upload_file() { | |
scp -i ${SSH_CERT} -P 22 "$1" ${REMOTE_USER}@${REMOTE_HOST}:"$2" | |
return $? | |
} | |
function upload_dir() { | |
scp -i ${SSH_CERT} -P 22 -r "$1" ${REMOTE_USER}@${REMOTE_HOST}:"$2" | |
return $? | |
} | |
upload_file "本地文件路径" "远端文件路径" || exit 1 | |
upload_dir "本地目录路径" "远端父目录路径(目录会存于该路径下)" || exit 1 | |
run_script "远端执行脚本" || exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment