Remove check_fingerprint function (ks-upX)

This commit is contained in:
q3aql 2023-02-10 13:11:36 +01:00
parent 20b928a291
commit 1e27c06547
4 changed files with 60 additions and 300 deletions

View File

@ -130,65 +130,6 @@ function showPathFile() {
echo ${pathFile} echo ${pathFile}
} }
# Function to check and save fingerprint SSH
# 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")
portSelected=$(cat ${dirConfig}/ks-upload-port)
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Rerun or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Re-run or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
fi
fi
fi
}
# Function to send file to server. # Function to send file to server.
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name] # Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
function sendFile() { function sendFile() {
@ -200,35 +141,35 @@ function sendFile() {
# Run command for upload on Windows (Cygwin) # Run command for upload on Windows (Cygwin)
if [ "${cygwin}" == "yes" ] ; then if [ "${cygwin}" == "yes" ] ; then
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
else else
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
fi fi
# Run command for upload on Unix systems # Run command for upload on Unix systems
else else
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
else else
sshpass -p ${1} scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
fi fi
fi fi
@ -259,21 +200,21 @@ function checkChecksum() {
if [ "${cygwin}" == "yes" ] ; then if [ "${cygwin}" == "yes" ] ; then
if [ -z "${toolSelected}" ] ; then if [ -z "${toolSelected}" ] ; then
checksumLocal=$(/usr/bin/md5sum ${2}) checksumLocal=$(/usr/bin/md5sum ${2})
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
else else
checksumLocal=$(/usr/bin/md5sum ${2}) checksumLocal=$(/usr/bin/md5sum ${2})
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
fi fi
else else
if [ -z "${toolSelected}" ] ; then if [ -z "${toolSelected}" ] ; then
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
checksumServer=$(sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
else else
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
fi fi
fi fi
@ -747,7 +688,6 @@ elif [ "${1}" == "-i" ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
check_fingerprint ${user} ${server}
echo -n "* Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then

View File

@ -157,65 +157,6 @@ function showPathFile() {
echo ${pathFile} echo ${pathFile}
} }
# Function to check and save fingerprint SSH
# 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")
portSelected=$(cat ${dirConfig}/ks-upload-port)
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Rerun or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Re-run or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
fi
fi
fi
}
# Function to send file to server. # Function to send file to server.
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name] # Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
function sendFile() { function sendFile() {
@ -227,35 +168,35 @@ function sendFile() {
# Run command for upload on Windows (Cygwin) # Run command for upload on Windows (Cygwin)
if [ "${cygwin}" == "yes" ] ; then if [ "${cygwin}" == "yes" ] ; then
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
else else
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
fi fi
# Run command for upload on Unix systems # Run command for upload on Unix systems
else else
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
else else
sshpass -p ${1} scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
fi fi
fi fi
@ -286,21 +227,21 @@ function checkChecksum() {
if [ "${cygwin}" == "yes" ] ; then if [ "${cygwin}" == "yes" ] ; then
if [ -z "${toolSelected}" ] ; then if [ -z "${toolSelected}" ] ; then
checksumLocal=$(/usr/bin/md5sum ${2}) checksumLocal=$(/usr/bin/md5sum ${2})
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
else else
checksumLocal=$(/usr/bin/md5sum ${2}) checksumLocal=$(/usr/bin/md5sum ${2})
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
fi fi
else else
if [ -z "${toolSelected}" ] ; then if [ -z "${toolSelected}" ] ; then
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
checksumServer=$(sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
else else
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
fi fi
fi fi
@ -774,7 +715,6 @@ elif [ "${1}" == "-i" ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
check_fingerprint ${user} ${server}
echo -n "* Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then

View File

@ -140,65 +140,6 @@ function showFile() {
echo ${archive} echo ${archive}
} }
# Function to check and save fingerprint SSH
# 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")
portSelected=$(cat ${dirConfig}/ks-upload-port)
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Rerun or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Re-run or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
fi
fi
fi
}
# Function to send file to server. # Function to send file to server.
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name] # Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
function sendFile() { function sendFile() {
@ -208,42 +149,42 @@ function sendFile() {
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
echo "" echo ""
echo "+ Syncing folder ${2} to ${5} (${4})" echo "+ Syncing folder ${2} to ${5} (${4})"
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
echo "" echo ""
echo "+ Syncing folder ${2} to ${5} (${4})" 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 -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
echo "" echo ""
echo "+ Sending files from ${2} to ${5} (${4})" echo "+ Sending files from ${2} to ${5} (${4})"
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
else else
echo "" echo ""
echo "+ Sending files from ${2} to ${5} (${4})" echo "+ Sending files from ${2} to ${5} (${4})"
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
fi fi
# Run command for upload on Unix systems # Run command for upload on Unix systems
else else
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
echo "" echo ""
echo "+ Syncing folder ${2} to ${5} (${4})" echo "+ Syncing folder ${2} to ${5} (${4})"
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
echo "" echo ""
echo "+ Syncing folder ${2} to ${5} (${4})" echo "+ Syncing folder ${2} to ${5} (${4})"
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2}/ ${4}:${5}/ 2> /dev/null
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
echo "" echo ""
echo "+ Sending files from ${2} to ${5} (${4})" echo "+ Sending files from ${2} to ${5} (${4})"
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
else else
echo "" echo ""
echo "+ Sending files from ${2} to ${5} (${4})" echo "+ Sending files from ${2} to ${5} (${4})"
sshpass -p ${1} scp -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} -r ${2}/* ${3}@${4}:${5}/ 2> /dev/null
fi fi
fi fi
} }
@ -702,7 +643,6 @@ elif [ "${1}" == "-i" ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
check_fingerprint ${user} ${server}
echo -n "* Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
current_tool=$(cat ${dirConfig}/ks-upload-tool) current_tool=$(cat ${dirConfig}/ks-upload-tool)

View File

@ -130,65 +130,6 @@ function showPathFile() {
echo ${pathFile} echo ${pathFile}
} }
# Function to check and save fingerprint SSH
# 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")
portSelected=$(cat ${dirConfig}/ks-upload-port)
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Rerun or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
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 -p ${portSelected} ${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 -p ${portSelected} ${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."
echo "* INFO: Re-run or check password."
echo ""
exit
else
echo "# ${2} cipher mark for ks-tools" >> ${HOME}/.ssh/known_hosts
fi
fi
fi
}
# Function to send file to server. # Function to send file to server.
# Syntax: sendFile <password> <file path> <user> <server> <server path> [file name] # Syntax: sendFile <password> <file path> <user> <server> <server path> [file name]
function sendFile() { function sendFile() {
@ -200,35 +141,35 @@ function sendFile() {
# Run command for upload on Windows (Cygwin) # Run command for upload on Windows (Cygwin)
if [ "${cygwin}" == "yes" ] ; then if [ "${cygwin}" == "yes" ] ; then
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
/usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null /usr/bin/rsync --progress -azL --rsh="/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
/usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
else else
/usr/bin/sshpass -p ${1} /usr/bin/scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null /usr/bin/sshpass -p ${1} /usr/bin/scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
fi fi
# Run command for upload on Unix systems # Run command for upload on Unix systems
else else
if [ "${toolSelected}" == "rsync" ] ; then if [ "${toolSelected}" == "rsync" ] ; then
rsync --progress -azL --rsh="sshpass -p ${1} ssh -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "rsync-rsa" ] ; then elif [ "${toolSelected}" == "rsync-rsa" ] ; then
rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null rsync --progress -azL --rsh="sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} -l ${3}" ${2} ${4}:${5} 2> /dev/null
sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} rm -rf ${5}/.${6}.* &> /dev/null
OUTPUT=$? OUTPUT=$?
elif [ "${toolSelected}" == "scp-rsa" ] ; then elif [ "${toolSelected}" == "scp-rsa" ] ; then
sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null sshpass -p ${1} scp -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
else else
sshpass -p ${1} scp -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null sshpass -p ${1} scp -o StrictHostKeyChecking=no -o CheckHostIP=no -P ${portSelected} ${2} ${3}@${4}:${5} 2> /dev/null
OUTPUT=$? OUTPUT=$?
fi fi
fi fi
@ -259,21 +200,21 @@ function checkChecksum() {
if [ "${cygwin}" == "yes" ] ; then if [ "${cygwin}" == "yes" ] ; then
if [ -z "${toolSelected}" ] ; then if [ -z "${toolSelected}" ] ; then
checksumLocal=$(/usr/bin/md5sum ${2}) checksumLocal=$(/usr/bin/md5sum ${2})
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
else else
checksumLocal=$(/usr/bin/md5sum ${2}) checksumLocal=$(/usr/bin/md5sum ${2})
checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(/usr/bin/sshpass -p ${1} /usr/bin/ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
fi fi
else else
if [ -z "${toolSelected}" ] ; then if [ -z "${toolSelected}" ] ; then
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
checksumServer=$(sshpass -p ${1} ssh -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
else else
checksumLocal=$(md5sum ${2}) checksumLocal=$(md5sum ${2})
checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null) checksumServer=$(sshpass -p ${1} ssh -o HostKeyAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -o CheckHostIP=no -p ${portSelected} ${3}@${4} md5sum ${5} 2> /dev/null)
OUTPUT=$? OUTPUT=$?
fi fi
fi fi
@ -748,7 +689,6 @@ elif [ "${1}" == "-i" ] ; then
dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirServer=$(cat ${dirConfig}/ks-upload-dirserver)
dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal)
# Call the functions to perform the whole process. # Call the functions to perform the whole process.
check_fingerprint ${user} ${server}
echo -n "* Scanning ${dirLocal} " && sleep 4 echo -n "* Scanning ${dirLocal} " && sleep 4
echo "" echo ""
if [ -d ${dirLocal} ] ; then if [ -d ${dirLocal} ] ; then