Add check first connection to save fingerprint
This commit is contained in:
parent
573a691fac
commit
e2f294877c
42
src/ks-upa
42
src/ks-upa
|
@ -129,6 +129,47 @@ 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}")
|
||||||
|
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.
|
# 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() {
|
||||||
|
@ -616,6 +657,7 @@ 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
|
||||||
|
|
42
src/ks-upf
42
src/ks-upf
|
@ -147,6 +147,47 @@ 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}")
|
||||||
|
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.
|
# 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() {
|
||||||
|
@ -634,6 +675,7 @@ 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
|
||||||
|
|
45
src/ks-upr
45
src/ks-upr
|
@ -140,11 +140,45 @@ function showFile() {
|
||||||
echo ${archive}
|
echo ${archive}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to show full file path.
|
# Function to check and save fingerprint SSH
|
||||||
# Syntax: showPathFile <file number>
|
# check_fingerprint <user> <server>
|
||||||
function showPathFile() {
|
function check_fingerprint() {
|
||||||
pathFile=$(cat ${dirTemp}/${listCompTemp} | head -${1} | tail -1)
|
fingerprint_host=$(cat ${HOME}/.ssh/known_hosts 2> /dev/null | grep -o "${2}")
|
||||||
echo ${pathFile}
|
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.
|
# Function to send file to server.
|
||||||
|
@ -589,6 +623,7 @@ 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)
|
||||||
|
|
42
src/ks-upv
42
src/ks-upv
|
@ -129,6 +129,47 @@ 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}")
|
||||||
|
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.
|
# 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() {
|
||||||
|
@ -617,6 +658,7 @@ 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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user