From 92269fe4c30033f3cdeb9bfb48bfbec84996d49f Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Tue, 2 Jun 2020 20:44:46 -0500 Subject: [PATCH] Test new SSH function --- CHANGELOG.md | 11 +++++++---- gravity-sync.sh | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59205ae..647b182 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # The Changelog +## 1.8 +### The Logical Release + +- All of the SSH connection logic has been rewritten to be specific to client options between OpenSSH, OpenSSH w/ SSHPASS, and Dropbear. +- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. +- Better error handling of configuration options. + ## 1.7 ### The Andrew Release @@ -11,10 +18,6 @@ **Known Issues** - No new Star Trek references. -#### 1.7.8 -- Removes INFO that SSHPASS is not installed during config, if it's not needed. Redirects user to documentation. -- Better error handling of configuration options. - #### 1.7.7 - `config` function will attempt to ping remote host to validate network connection, can by bypassed by adding `PING_AVOID='1'` to your `gravity-sync.conf` file. - Changes some [INFO] messages to [WARN] where approprate. diff --git a/gravity-sync.sh b/gravity-sync.sh index 0d74083..9a91953 100755 --- a/gravity-sync.sh +++ b/gravity-sync.sh @@ -617,23 +617,47 @@ function validate_os_sshpass { MESSAGE="Validating Connection to ${REMOTE_HOST}" echo_stat + + ssh_function + + CMD_TIMEOUT='5' + CMD_REQUESTED="exit" + ${SSH_SEND} + error_validate + if hash ssh 2>/dev/null then if [ -z "$SSHPASSWORD" ] then - timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + # timeout 5 ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + # error_validate else - timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + # error_validate fi elif hash dbclient 2>/dev/null then - timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 - error_validate + # timeout 5 ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -i "$HOME/${SSH_PKIF}" ${REMOTE_USER}@${REMOTE_HOST} 'exit' >/dev/null 2>&1 + # error_validate fi } +## Determine SSH Pathways +function ssh_function { + if hash ssh 2>/dev/null + then + if [ -z "$SSHPASSWORD" ] + then + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + else + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSHPASSWORD} ${SSH_CMD} -p ${SSH_PORT} -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + fi + elif hash dbclient 2>/dev/null + then + SSH_SEND="timeout ${CMD_TIMEOUT} ${SSH_CMD} -p ${SSH_PORT} -i \"$HOME/${SSH_PKIF}\" ${REMOTE_USER}@${REMOTE_HOST} \"${CMD_REQUESTED}\"" + fi +} + ## Detect SSH-KEYGEN function detect_sshkeygen { MESSAGE="Validating SSH-KEYGEN install on $HOSTNAME"