diff --git a/src/ks-upa b/src/ks-upa index 7d61e38..f0fc90f 100755 --- a/src/ks-upa +++ b/src/ks-upa @@ -129,6 +129,47 @@ function showPathFile() { echo ${pathFile} } +# Function to check and save fingerprint SSH +# check_fingerprint +function check_fingerprint() { + fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}") + if [ -z "${fingerprint_host}" ] ; then + # Run command for upload on Windows (Cygwin) + if [ "${cygwin}" == "yes" ] ; 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=$? + 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 + 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=$? + 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. # Syntax: sendFile [file name] function sendFile() { @@ -616,6 +657,7 @@ elif [ "${1}" == "-i" ] ; then dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) # Call the functions to perform the whole process. + check_fingerprint ${user} ${server} echo -n "* Scanning ${dirLocal} " && sleep 4 echo "" if [ -d ${dirLocal} ] ; then diff --git a/src/ks-upf b/src/ks-upf index e878c8d..c773b82 100755 --- a/src/ks-upf +++ b/src/ks-upf @@ -147,6 +147,47 @@ function showPathFile() { echo ${pathFile} } +# Function to check and save fingerprint SSH +# check_fingerprint +function check_fingerprint() { + fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}") + if [ -z "${fingerprint_host}" ] ; then + # Run command for upload on Windows (Cygwin) + if [ "${cygwin}" == "yes" ] ; 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=$? + 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 + 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=$? + 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. # Syntax: sendFile [file name] function sendFile() { @@ -634,6 +675,7 @@ elif [ "${1}" == "-i" ] ; then dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) # Call the functions to perform the whole process. + check_fingerprint ${user} ${server} echo -n "* Scanning ${dirLocal} " && sleep 4 echo "" if [ -d ${dirLocal} ] ; then diff --git a/src/ks-upr b/src/ks-upr index c72de1e..e1bed7a 100755 --- a/src/ks-upr +++ b/src/ks-upr @@ -140,11 +140,45 @@ function showFile() { echo ${archive} } -# Function to show full file path. -# Syntax: showPathFile -function showPathFile() { - pathFile=$(cat ${dirTemp}/${listCompTemp} | head -${1} | tail -1) - echo ${pathFile} +# Function to check and save fingerprint SSH +# check_fingerprint +function check_fingerprint() { + fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}") + if [ -z "${fingerprint_host}" ] ; then + # Run command for upload on Windows (Cygwin) + if [ "${cygwin}" == "yes" ] ; 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=$? + 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 + 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=$? + 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. @@ -589,6 +623,7 @@ elif [ "${1}" == "-i" ] ; then dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) # Call the functions to perform the whole process. + check_fingerprint ${user} ${server} echo -n "* Scanning ${dirLocal} " && sleep 4 echo "" current_tool=$(cat ${dirConfig}/ks-upload-tool) diff --git a/src/ks-upv b/src/ks-upv index 0c6500f..7069329 100755 --- a/src/ks-upv +++ b/src/ks-upv @@ -129,6 +129,47 @@ function showPathFile() { echo ${pathFile} } +# Function to check and save fingerprint SSH +# check_fingerprint +function check_fingerprint() { + fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}") + if [ -z "${fingerprint_host}" ] ; then + # Run command for upload on Windows (Cygwin) + if [ "${cygwin}" == "yes" ] ; 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=$? + 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 + 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=$? + 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. # Syntax: sendFile [file name] function sendFile() { @@ -617,6 +658,7 @@ elif [ "${1}" == "-i" ] ; then dirServer=$(cat ${dirConfig}/ks-upload-dirserver) dirLocal=$(cat ${dirConfig}/ks-upload-dirlocal) # Call the functions to perform the whole process. + check_fingerprint ${user} ${server} echo -n "* Scanning ${dirLocal} " && sleep 4 echo "" if [ -d ${dirLocal} ] ; then