Add option for legacy RSA Algorithm
This commit is contained in:
parent
9e970d5e37
commit
209c2167ab
BIN
src/.ks-upa.swp
Normal file
BIN
src/.ks-upa.swp
Normal file
Binary file not shown.
BIN
src/.ks-upf.swp
Normal file
BIN
src/.ks-upf.swp
Normal file
Binary file not shown.
BIN
src/.ks-upr.swp
Normal file
BIN
src/.ks-upr.swp
Normal file
Binary file not shown.
BIN
src/.ks-upv.swp
Normal file
BIN
src/.ks-upv.swp
Normal file
Binary file not shown.
75
src/ks-upa
75
src/ks-upa
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
#####################################################################
|
||||
# ks-upa (ks-tools) - Upload audio file(s) to server with rsync+ssh #
|
||||
########################################################################
|
||||
# ks-upa (ks-tools) - Upload audio file(s) to server with scp or rsync #
|
||||
# Date: 22-01-2022 #
|
||||
# Author: q3aql #
|
||||
# Contact: q3aql@duck.com #
|
||||
#####################################################################
|
||||
########################################################################
|
||||
VERSION="8.2"
|
||||
M_DATE="220122"
|
||||
|
||||
|
@ -134,14 +134,23 @@ function showPathFile() {
|
|||
# check_fingerprint <user> <server>
|
||||
function check_fingerprint() {
|
||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
if [ -z "${fingerprint_host}" ] ; then
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -153,11 +162,19 @@ function check_fingerprint() {
|
|||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -184,6 +201,13 @@ function sendFile() {
|
|||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
|
@ -194,6 +218,13 @@ function sendFile() {
|
|||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
|
@ -220,15 +251,28 @@ function checkChecksum() {
|
|||
countChecksum=0
|
||||
echo -n "Checking checksum... " && sleep 4
|
||||
echo ""
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
fi
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
fi
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
|
@ -416,11 +460,25 @@ function editConfig() {
|
|||
dirLocal=${DIR}
|
||||
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
|
||||
elif [ "${EDIT}" == "6" ] ; then
|
||||
echo -n "* [Default: scp] Type upload tool (scp or rsync): " ; read TOOL
|
||||
echo ""
|
||||
echo "* Available options:"
|
||||
echo ""
|
||||
echo "- scp"
|
||||
echo "- rsync"
|
||||
echo "- scp-rsa (legacy RSA algorithm)"
|
||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||
echo ""
|
||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa): " ; read TOOL
|
||||
if [ -z "${TOOL}" ] ; then
|
||||
upvTool="scp"
|
||||
elif [ "${TOOL}" == "rsync" ] ; then
|
||||
upvTool="rsync"
|
||||
elif [ "${TOOL}" == "rsync-rsa" ] ; then
|
||||
upvTool="rsync-rsa"
|
||||
elif [ "${TOOL}" == "scp-rsa" ] ; then
|
||||
upvTool="scp-rsa"
|
||||
else
|
||||
upvTool=${TOOL}
|
||||
upvTool="scp"
|
||||
fi
|
||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||
elif [ "${EDIT}" == "7" ] ; then
|
||||
|
@ -504,7 +562,7 @@ function showHelp() {
|
|||
echo ""
|
||||
echo "* ks-upa (ks-tools) v${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "- Upload audio file(s) to server with rsync+ssh"
|
||||
echo "- Upload audio file(s) to server with scp or rsync"
|
||||
echo ""
|
||||
echo "+ Syntax:"
|
||||
echo ""
|
||||
|
@ -673,6 +731,11 @@ elif [ "${1}" == "-i" ] ; then
|
|||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
echo ""
|
||||
fi
|
||||
if [ "${current_tool}" == "scp-rsa" ] ; then
|
||||
echo "* NOTE: You are using 'scp' to upload files and no progress will be shown."
|
||||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
echo ""
|
||||
fi
|
||||
while [ ${count} -le ${totalFiles} ] ; do
|
||||
fullNameFile=$(showFile ${count})
|
||||
fullPathFile=$(showPathFile ${count})
|
||||
|
|
75
src/ks-upf
75
src/ks-upf
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
######################################################################
|
||||
# ks-upf (ks-tools) - Upload common file(s) to server with rsync+ssh #
|
||||
#########################################################################
|
||||
# ks-upf (ks-tools) - Upload common file(s) to server with scp or rsync #
|
||||
# Date: 22-01-2022 #
|
||||
# Author: q3aql #
|
||||
# Contact: q3aql@duck.com #
|
||||
######################################################################
|
||||
#########################################################################
|
||||
VERSION="8.2"
|
||||
M_DATE="220122"
|
||||
|
||||
|
@ -161,14 +161,23 @@ function showPathFile() {
|
|||
# check_fingerprint <user> <server>
|
||||
function check_fingerprint() {
|
||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
if [ -z "${fingerprint_host}" ] ; then
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -180,11 +189,19 @@ function check_fingerprint() {
|
|||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -211,6 +228,13 @@ function sendFile() {
|
|||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
|
@ -221,6 +245,13 @@ function sendFile() {
|
|||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
|
@ -247,15 +278,28 @@ function checkChecksum() {
|
|||
countChecksum=0
|
||||
echo -n "Checking checksum... " && sleep 4
|
||||
echo ""
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
fi
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
fi
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
|
@ -443,11 +487,25 @@ function editConfig() {
|
|||
dirLocal=${DIR}
|
||||
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
|
||||
elif [ "${EDIT}" == "6" ] ; then
|
||||
echo -n "* [Default: scp] Type upload tool (scp or rsync): " ; read TOOL
|
||||
echo ""
|
||||
echo "* Available options:"
|
||||
echo ""
|
||||
echo "- scp"
|
||||
echo "- rsync"
|
||||
echo "- scp-rsa (legacy RSA algorithm)"
|
||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||
echo ""
|
||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa): " ; read TOOL
|
||||
if [ -z "${TOOL}" ] ; then
|
||||
upvTool="scp"
|
||||
elif [ "${TOOL}" == "rsync" ] ; then
|
||||
upvTool="rsync"
|
||||
elif [ "${TOOL}" == "rsync-rsa" ] ; then
|
||||
upvTool="rsync-rsa"
|
||||
elif [ "${TOOL}" == "scp-rsa" ] ; then
|
||||
upvTool="scp-rsa"
|
||||
else
|
||||
upvTool=${TOOL}
|
||||
upvTool="scp"
|
||||
fi
|
||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||
elif [ "${EDIT}" == "7" ] ; then
|
||||
|
@ -531,7 +589,7 @@ function showHelp() {
|
|||
echo ""
|
||||
echo "* ks-upf (ks-tools) v${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "- Upload common file(s) to server with rsync+ssh"
|
||||
echo "- Upload common file(s) to server with scp or rsync"
|
||||
echo ""
|
||||
echo "+ Syntax:"
|
||||
echo ""
|
||||
|
@ -700,6 +758,11 @@ elif [ "${1}" == "-i" ] ; then
|
|||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
echo ""
|
||||
fi
|
||||
if [ "${current_tool}" == "scp-rsa" ] ; then
|
||||
echo "* NOTE: You are using 'scp' to upload files and no progress will be shown."
|
||||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
echo ""
|
||||
fi
|
||||
while [ ${count} -le ${totalFiles} ] ; do
|
||||
fullNameFile=$(showFile ${count})
|
||||
fullPathFile=$(showPathFile ${count})
|
||||
|
|
66
src/ks-upr
66
src/ks-upr
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
###########################################################################
|
||||
# ks-upr (ks-tools) - Upload recursively file(s) to server with rsync+ssh #
|
||||
##############################################################################
|
||||
# ks-upr (ks-tools) - Upload recursively file(s) to server with scp or rsync #
|
||||
# Date: 22-01-2022 #
|
||||
# Author: q3aql #
|
||||
# Contact: q3aql@duck.com #
|
||||
###########################################################################
|
||||
##############################################################################
|
||||
VERSION="8.2"
|
||||
M_DATE="220122"
|
||||
|
||||
|
@ -144,14 +144,23 @@ function showFile() {
|
|||
# check_fingerprint <user> <server>
|
||||
function check_fingerprint() {
|
||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
if [ -z "${fingerprint_host}" ] ; then
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -163,11 +172,19 @@ function check_fingerprint() {
|
|||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -191,6 +208,15 @@ function sendFile() {
|
|||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
echo ""
|
||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
echo ""
|
||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||
else
|
||||
echo ""
|
||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||
|
@ -203,6 +229,15 @@ function sendFile() {
|
|||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
echo ""
|
||||
echo "+ Syncing folder ${2} to ${5} (${4})"
|
||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
|
||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
echo ""
|
||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
|
||||
else
|
||||
echo ""
|
||||
echo "+ Sending files from ${2} to ${5} (${4})"
|
||||
|
@ -381,11 +416,25 @@ function editConfig() {
|
|||
dirLocal=${DIR}
|
||||
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
|
||||
elif [ "${EDIT}" == "6" ] ; then
|
||||
echo -n "* [Default: scp] Type upload tool (scp or rsync): " ; read TOOL
|
||||
echo ""
|
||||
echo "* Available options:"
|
||||
echo ""
|
||||
echo "- scp"
|
||||
echo "- rsync"
|
||||
echo "- scp-rsa (legacy RSA algorithm)"
|
||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||
echo ""
|
||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa): " ; read TOOL
|
||||
if [ -z "${TOOL}" ] ; then
|
||||
upvTool="scp"
|
||||
elif [ "${TOOL}" == "rsync" ] ; then
|
||||
upvTool="rsync"
|
||||
elif [ "${TOOL}" == "rsync-rsa" ] ; then
|
||||
upvTool="rsync-rsa"
|
||||
elif [ "${TOOL}" == "scp-rsa" ] ; then
|
||||
upvTool="scp-rsa"
|
||||
else
|
||||
upvTool=${TOOL}
|
||||
upvTool="scp"
|
||||
fi
|
||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||
elif [ "${EDIT}" == "7" ] ; then
|
||||
|
@ -469,7 +518,7 @@ function showHelp() {
|
|||
echo ""
|
||||
echo "* ks-upr (ks-tools) v${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "- Upload recursively file(s) to server with rsync+ssh"
|
||||
echo "- Upload recursively file(s) to server with scp or rsync"
|
||||
echo ""
|
||||
echo "+ Syntax:"
|
||||
echo ""
|
||||
|
@ -632,6 +681,11 @@ elif [ "${1}" == "-i" ] ; then
|
|||
echo "* NOTE: You are using 'scp' to upload files and no progress will be shown."
|
||||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
fi
|
||||
if [ "${current_tool}" == "scp-rsa" ] ; then
|
||||
echo ""
|
||||
echo "* NOTE: You are using 'scp' to upload files and no progress will be shown."
|
||||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
fi
|
||||
if [ -d ${dirLocal} ] ; then
|
||||
sendFile ${password} "${dirLocal}" ${user} ${server} ${dirServer}
|
||||
echo ""
|
||||
|
|
75
src/ks-upv
75
src/ks-upv
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
######################################################################
|
||||
# ks-upv (ks-tools) - Upload videos file(s) to server with rynsc+ssh #
|
||||
#########################################################################
|
||||
# ks-upv (ks-tools) - Upload videos file(s) to server with scp or rsync #
|
||||
# Date: 22-01-2022 #
|
||||
# Author: q3aql #
|
||||
# Contact: q3aql@duck.com #
|
||||
######################################################################
|
||||
#########################################################################
|
||||
VERSION="8.2"
|
||||
M_DATE="220122"
|
||||
|
||||
|
@ -134,14 +134,23 @@ function showPathFile() {
|
|||
# check_fingerprint <user> <server>
|
||||
function check_fingerprint() {
|
||||
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
if [ -z "${fingerprint_host}" ] ; then
|
||||
# Run command for upload on Windows (Cygwin)
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
/usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -153,11 +162,19 @@ function check_fingerprint() {
|
|||
fi
|
||||
# Run command for upload on Unix systems
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
echo "* INFO: First connection to a server requires saving the fingerprint."
|
||||
echo "* INFO: Only the first time you will have to enter the password."
|
||||
echo ""
|
||||
ssh -o HostKeyAlgorithms=+ssh-rsa ${1}@${2} echo "* Connection successfuly" &> /dev/null
|
||||
OUTPUT=$?
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo ""
|
||||
echo "+ ERROR: There has been a failure to connect to the server."
|
||||
|
@ -184,6 +201,13 @@ function sendFile() {
|
|||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
/usr/bin/sshpass -p ${1} /usr/bin/scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
|
@ -194,6 +218,13 @@ function sendFile() {
|
|||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
sshpass -p ${1} ssh ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "rsync-rsa" ] ; then
|
||||
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -l ${3}" ${2} ${4}:${5} 2> /dev/null
|
||||
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
|
||||
OUTPUT=$?
|
||||
elif [ "${toolSelected}" == "scp-rsa" ] ; then
|
||||
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
else
|
||||
sshpass -p ${1} scp ${2} ${3}@${4}:${5} 2> /dev/null
|
||||
OUTPUT=$?
|
||||
|
@ -220,15 +251,28 @@ function checkChecksum() {
|
|||
countChecksum=0
|
||||
echo -n "Checking checksum... " && sleep 4
|
||||
echo ""
|
||||
toolSelected=$(cat ${dirConfig}/ks-upload-tool | grep "rsa")
|
||||
while [ ${correct} -eq 0 ] ; do
|
||||
if [ "${cygwin}" == "yes" ] ; then
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(/usr/bin/md5sum ${2})
|
||||
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
fi
|
||||
else
|
||||
if [ -z "${toolSelected}" ] ; then
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
else
|
||||
checksumLocal=$(md5sum ${2})
|
||||
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa ${3}@${4} md5sum ${5} 2> /dev/null)
|
||||
OUTPUT=$?
|
||||
fi
|
||||
fi
|
||||
if [ ${OUTPUT} -ne 0 ] ; then
|
||||
echo "Failed to get checksum for ${5}"
|
||||
|
@ -416,11 +460,25 @@ function editConfig() {
|
|||
dirLocal=${DIR}
|
||||
echo ${dirLocal} > ${dirConfig}/ks-upload-dirlocal
|
||||
elif [ "${EDIT}" == "6" ] ; then
|
||||
echo -n "* [Default: scp] Type upload tool (scp or rsync): " ; read TOOL
|
||||
echo ""
|
||||
echo "* Available options:"
|
||||
echo ""
|
||||
echo "- scp"
|
||||
echo "- rsync"
|
||||
echo "- scp-rsa (legacy RSA algorithm)"
|
||||
echo "- rsync-rsa (legacy RSA algorithm)"
|
||||
echo ""
|
||||
echo -n "* [Default: scp] Type upload tool (scp/rsync/scp-rsa/rsync-rsa): " ; read TOOL
|
||||
if [ -z "${TOOL}" ] ; then
|
||||
upvTool="scp"
|
||||
elif [ "${TOOL}" == "rsync" ] ; then
|
||||
upvTool="rsync"
|
||||
elif [ "${TOOL}" == "rsync-rsa" ] ; then
|
||||
upvTool="rsync-rsa"
|
||||
elif [ "${TOOL}" == "scp-rsa" ] ; then
|
||||
upvTool="scp-rsa"
|
||||
else
|
||||
upvTool=${TOOL}
|
||||
upvTool="scp"
|
||||
fi
|
||||
echo ${upvTool} > ${dirConfig}/ks-upload-tool
|
||||
elif [ "${EDIT}" == "7" ] ; then
|
||||
|
@ -504,7 +562,7 @@ function showHelp() {
|
|||
echo ""
|
||||
echo "* ks-upv (ks-tools) v${VERSION} (${M_DATE})"
|
||||
echo ""
|
||||
echo "- Upload videos file(s) to server with rynsc+ssh"
|
||||
echo "- Upload videos file(s) to server with scp or rsync"
|
||||
echo ""
|
||||
echo "+ Syntax:"
|
||||
echo ""
|
||||
|
@ -674,6 +732,11 @@ elif [ "${1}" == "-i" ] ; then
|
|||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
echo ""
|
||||
fi
|
||||
if [ "${current_tool}" == "scp-rsa" ] ; then
|
||||
echo "* NOTE: You are using 'scp' to upload files and no progress will be shown."
|
||||
echo "* IMPORTANT: It's possible switch to 'rsync' if you wish (Command: ks-upv -e)"
|
||||
echo ""
|
||||
fi
|
||||
while [ ${count} -le ${totalFiles} ] ; do
|
||||
fullNameFile=$(showFile ${count})
|
||||
fullPathFile=$(showPathFile ${count})
|
||||
|
|
Loading…
Reference in New Issue
Block a user