diff --git a/script/tools/sshcmd.sh b/script/tools/sshcmd.sh index ae8ad39b7eae3c7d3176f87ab9633b9c105a38bd..b09c05f91ba16215c70bd4c1a3845415f46712b2 100644 --- a/script/tools/sshcmd.sh +++ b/script/tools/sshcmd.sh @@ -117,6 +117,28 @@ do esac done + +function sshcmd_stable() +{ + cmd="$1" + destip="$2" + user=${3-root} + timeout=180 + + if [ "x${destip}" = "x" ]; then + destip="${testmachine}" + fi + if [ "x${destip}" = "x" -o "x${cmd}" = "x" ];then + echo "destip or cmd is empty." + exit 1 + fi + + cmd=${cmd//\"/\\\"} + cmd=${cmd//\$/\\\$} + + ssh -i ~/.ssh/super_publish_rsa -o "ConnectTimeout ${timeout}" -o StrictHostKeyChecking=no -o ServerAliveInterval=60 ${SSHPORT} "${user}@${destip}" "${cmd}" +} + ###################### # delet known hosts # Globals: @@ -147,6 +169,6 @@ if [ "x${execcmd}" = "x" -o "x${machineip}" = "x" ];then fi delete_known_hosts -sshcmd_comm "${execcmd}" "${machineip}" "${loginpassword}" "${loginuser}" +sshcmd_stable "${execcmd}" "${machineip}" "${loginuser}" exit $? diff --git a/script/tools/sshscp.sh b/script/tools/sshscp.sh index cef0ea8fbf7df5ba2364a0083d03cd356054fa7c..21da46eebb182bf80796e9666b663672dad8ae34 100644 --- a/script/tools/sshscp.sh +++ b/script/tools/sshscp.sh @@ -101,6 +101,26 @@ function sshcmd_comm() return $? } +function sshcmd_stable() +{ + srccommand="$1" + descommand="$2" + local r_option="$3" + timeout=180 + + if [ "x${srccommand}" = "x" -o "x${descommand}" = "x" ];then + echo "srccommand or descommand is empty." + exit 1 + fi + + if [ "${r_option}" = "1" ]; then + r_option="-r" + else + r_option="" + fi + + scp -i ~/.ssh/super_publish_rsa -o "ConnectTimeout ${timeout}" -o StrictHostKeyChecking=no -o ServerAliveInterval=60 ${SCPPORT} "${r_option}" "${srccommand}" "${descommand}" +} ###################### # 清空/root/.ssh/known_hosts 文件 @@ -156,6 +176,6 @@ fi delete_known_hosts for src_item in $(echo "${src}") do - sshcmd_comm "${src_item}" "${des}" "${loginpassword}" "${r_option_value}" + sshcmd_stable "${src_item}" "${des}" "${r_option_value}" done exit $?