From 87246e429859f8ed3ab4de645bcfeeb36f5cc24a Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 27 May 2020 15:49:57 -0500 Subject: [PATCH] Fixes places where SSH_PORT and SSH_PKIF were not utilized --- gravity-sync.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gravity-sync.sh b/gravity-sync.sh index 1a8d21f..1f9465e 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -125,7 +125,7 @@ function pull_gs { MESSAGE="Pulling ${GRAVITY_FI} from ${REMOTE_HOST}" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 + ${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT} -i ${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.pull >/dev/null 2>&1 error_validate MESSAGE="Replacing ${GRAVITY_FI} on $HOSTNAME" @@ -203,22 +203,22 @@ function push_gs { MESSAGE="Backing Up ${GRAVITY_FI} from ${REMOTE_HOST}" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push >/dev/null 2>&1 + ${SSHPASSWORD} rsync -e "ssh -p ${SSH_PORT} -i ${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} $HOME/${LOCAL_FOLDR}/${BACKUP_FOLD}/${GRAVITY_FI}.push >/dev/null 2>&1 error_validate MESSAGE="Pushing ${GRAVITY_FI} to ${REMOTE_HOST}" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "ssh -p ${SSH_PORT}" ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 + ${SSHPASSWORD} rsync --rsync-path="sudo rsync" -e "ssh -p ${SSH_PORT} -i ${SSH_PKIF}" ${PIHOLE_DIR}/${GRAVITY_FI} ${REMOTE_USER}@${REMOTE_HOST}:${PIHOLE_DIR}/${GRAVITY_FI} >/dev/null 2>&1 error_validate MESSAGE="Setting Permissions on ${GRAVITY_FI}" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 + ${SSHPASSWORD} ssh -p ${SSH_PORT} -i ${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} "sudo chmod 664 ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 error_validate MESSAGE="Setting Ownership on ${GRAVITY_FI}" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 + ${SSHPASSWORD} ssh -p ${SSH_PORT} -i ${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} "sudo chown pihole:pihole ${PIHOLE_DIR}/${GRAVITY_FI}" >/dev/null 2>&1 error_validate MESSAGE="Contacting Borg Collective" @@ -227,12 +227,12 @@ function push_gs { MESSAGE="Updating FTLDNS Configuration" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns reloadlists" >/dev/null 2>&1 + ${SSHPASSWORD} ssh -p ${SSH_PORT} -i ${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns reloadlists" >/dev/null 2>&1 error_validate MESSAGE="Reloading FTLDNS Services" echo -en "${STAT} ${MESSAGE}" - ${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1 + ${SSHPASSWORD} ssh -p ${SSH_PORT} -i ${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} "${PIHOLE_BIN} restartdns" >/dev/null 2>&1 error_validate logs_export @@ -348,7 +348,7 @@ function validate_os_sshpass { SSHPASSWORD='' MESSAGE="Using SSH Key-Pair Authentication" else - timeout 5 ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + timeout 5 ssh -p ${SSH_PORT} -i ${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 if [ "$?" != "0" ]; then SSHPASSWORD="sshpass -p ${REMOTE_PASS}" MESSAGE="Using SSH Password Authentication" @@ -367,7 +367,7 @@ function validate_os_sshpass { MESSAGE="Testing SSH Connection" echo -en "${STAT} ${MESSAGE}" - timeout 5 ${SSHPASSWORD} ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + timeout 5 ${SSHPASSWORD} ssh -p ${SSH_PORT} -i ${SSH_PKIF} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 error_validate } @@ -388,7 +388,7 @@ function md5_compare { MESSAGE="Analyzing Remote ${GRAVITY_FI}" echo -en "${STAT} ${MESSAGE}" - primaryMD5=$(${SSHPASSWORD} ssh ${REMOTE_USER}@${REMOTE_HOST} 'md5sum /etc/pihole/gravity.db') + primaryMD5=$(${SSHPASSWORD} ssh -p ${SSH_PORT} -i ${SSH_PKIF} ${REMOTE_USER}@${REMOTE_HOST} 'md5sum /etc/pihole/gravity.db') error_validate MESSAGE="Analyzing Local ${GRAVITY_FI}"