Add more SSH validation

This commit is contained in:
Michael Stanclift 2020-05-25 12:06:37 -05:00
parent 7984455df6
commit 1b158f0a2b

View File

@ -153,7 +153,7 @@ function push_gs {
echo -e "${INFO} ${TASKTYPE} Requested" echo -e "${INFO} ${TASKTYPE} Requested"
md5_compare md5_compare
echo -e "${WARN} Are you sure you want to overwrite the primary node configuration on ${REMOTE_HOST}?" echo -e "${WARN} Are you sure you want to overwrite the primary PH configuration on ${REMOTE_HOST}?"
select yn in "Yes" "No"; do select yn in "Yes" "No"; do
case $yn in case $yn in
Yes ) Yes )
@ -187,7 +187,6 @@ function push_gs {
MESSAGE="Reloading FTLDNS Services" MESSAGE="Reloading FTLDNS Services"
echo -e "${STAT} ${MESSAGE}" echo -e "${STAT} ${MESSAGE}"
ssh ${REMOTE_USER}@${REMOTE_HOST} 'pihole restartdns' ssh ${REMOTE_USER}@${REMOTE_HOST} 'pihole restartdns'
error_validate error_validate
@ -277,11 +276,18 @@ function validate_os_sshpass {
then then
if test -z "$REMOTE_PASS" if test -z "$REMOTE_PASS"
then then
sshpassword='' SSHPASSWORD=''
MESSAGE="Using SSH Key-Pair Authentication" MESSAGE="Using SSH Key-Pair Authentication"
else else
sshpassword="sshpass -p ${REMOTE_PASS} " ssh -o ConnectTimeout=5 -o BatchMode=yes -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit'
MESSAGE="Using SSH Password Authentication" if [ "$?" != "0" ]; then
SSHPASSWORD="sshpass -p ${REMOTE_PASS} "
MESSAGE="Using SSH Password Authentication"
else
sshpassword=''
MESSAGE="Using SSH Key-Pair Authentication"
fi
fi fi
else else
sshpassword='' sshpassword=''