Fixed several issues with ssh key copy process and remote communication
This commit is contained in:
parent
40f861804b
commit
8431ced241
@ -27,9 +27,8 @@
|
|||||||
# - Add support for databases
|
# - Add support for databases
|
||||||
# - Pre-Backup commands
|
# - Pre-Backup commands
|
||||||
# - Post-Backup commands
|
# - Post-Backup commands
|
||||||
|
# - Check for already existing backup repository
|
||||||
# Bugs:
|
# - Check for already existing borgmatic configuration file
|
||||||
# - On Ubuntu Server: always asking for password despite ssh key was successfully copied
|
|
||||||
|
|
||||||
# SETTINGS - Make sure to adjust these settings to your needs
|
# SETTINGS - Make sure to adjust these settings to your needs
|
||||||
DEBUG=0 # Set to 1 to enable debug mode
|
DEBUG=0 # Set to 1 to enable debug mode
|
||||||
@ -677,7 +676,7 @@ if ! inf_follow "Checking for default ssh key at $SSH_KEY_FILE..." "\e[1;32mYes\
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check first if ssh key is already present on the remote end
|
# check first if ssh key is already present on the remote end
|
||||||
if ! inf_follow "Checking if ssh key is already present on $SSH_HOST..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" exit; then
|
if ! inf_follow "Checking if ssh key is already present on $SSH_HOST..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -oStrictHostKeyChecking=no -oBatchMode=yes -i "$SSH_KEY_FILE" -p "$SSH_PORT" -l "$SSH_USER" "$SSH_HOST" exit; then
|
||||||
# ask for ssh password if none is set
|
# ask for ssh password if none is set
|
||||||
if [ -z "$SSH_PASSWORD" ]; then
|
if [ -z "$SSH_PASSWORD" ]; then
|
||||||
wrn "Please enter the password for the ssh key to copy it to the backup server."
|
wrn "Please enter the password for the ssh key to copy it to the backup server."
|
||||||
@ -687,13 +686,13 @@ if ! inf_follow "Checking if ssh key is already present on $SSH_HOST..." "\e[1;3
|
|||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! inf_follow "Copying ssh key to $SSH_HOST..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command sshpass -p "$SSH_PASSWORD" ssh-copy-id -i "$SSH_KEY_FILE" -p "$SSH_PORT" -o StrictHostKeyChecking=no "$SSH_USER@$SSH_HOST"; then
|
if ! inf_follow "Copying ssh key to $SSH_HOST..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command sshpass -p "$SSH_PASSWORD" ssh-copy-id -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes "$SSH_USER@$SSH_HOST"; then
|
||||||
err "Failed to copy ssh key to $SSH_HOST."
|
err "Failed to copy ssh key to $SSH_HOST."
|
||||||
err "Please validate your ssh password and and host settings and try again."
|
err "Please validate your ssh password and and host settings and try again."
|
||||||
err "If the error persists, please contact the support at $SCRIPT_SUPPORT."
|
err "If the error persists, please contact the support at $SCRIPT_SUPPORT."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
if ! inf_follow "Checking if ssh key is working..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" exit; then
|
if ! inf_follow "Checking if ssh key is working..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" exit; then
|
||||||
err "Failed to connect to $SSH_HOST using the ssh key."
|
err "Failed to connect to $SSH_HOST using the ssh key."
|
||||||
err "Please validate you have the correct ssh key and host settings."
|
err "Please validate you have the correct ssh key and host settings."
|
||||||
err "If the error persists, please contact the support at $SCRIPT_SUPPORT."
|
err "If the error persists, please contact the support at $SCRIPT_SUPPORT."
|
||||||
@ -702,7 +701,7 @@ if ! inf_follow "Checking if ssh key is already present on $SSH_HOST..." "\e[1;3
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! inf_follow "Checking if remote end has borg installed..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" borg --version; then
|
if ! inf_follow "Checking if remote end has borg installed..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" borg --version; then
|
||||||
if inf_follow "Checking if remote end is a Synology NAS..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" is_remote_synology; then
|
if inf_follow "Checking if remote end is a Synology NAS..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" is_remote_synology; then
|
||||||
IS_REMOTE_SYNOLGY=1
|
IS_REMOTE_SYNOLGY=1
|
||||||
fi
|
fi
|
||||||
@ -727,9 +726,9 @@ if ! inf_follow "Checking if remote end has borg installed..." "\e[1;32mYes\e[0m
|
|||||||
wrn ""
|
wrn ""
|
||||||
wrnw "Press any key to continue..."
|
wrnw "Press any key to continue..."
|
||||||
|
|
||||||
if ! inf_follow "Checking if remote end has borg installed..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" borg --version; then
|
if ! inf_follow "Checking if remote end has borg installed..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" borg --version; then
|
||||||
if inf_follow "Checking if borg was installed at /usr/local/bin..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" test -f /usr/local/bin/borg; then
|
if inf_follow "Checking if borg was installed at /usr/local/bin..." "\e[1;32mYes\e[0m" "\e[1;31mNo\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" test -f /usr/local/bin/borg; then
|
||||||
if inf_follow "Creating symlink to /bin/borg..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" ln -s /usr/local/bin/borg /bin/borg; then
|
if inf_follow "Creating symlink to /bin/borg..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" ln -s /usr/local/bin/borg /bin/borg; then
|
||||||
inf "Successfully created symlink to /bin/borg."
|
inf "Successfully created symlink to /bin/borg."
|
||||||
else
|
else
|
||||||
err "Failed to create symlink to /bin/borg."
|
err "Failed to create symlink to /bin/borg."
|
||||||
@ -747,13 +746,13 @@ if ! inf_follow "Checking if remote end has borg installed..." "\e[1;32mYes\e[0m
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if wrnp "The remote end does not have borg installed. Do you want to install it now? [y/N]"; then
|
if wrnp "The remote end does not have borg installed. Do you want to install it now? [y/N]"; then
|
||||||
if ! inf_follow "Updating package repositories on remote end" "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" apt-get update; then
|
if ! inf_follow "Updating package repositories on remote end" "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" apt-get update; then
|
||||||
err "Failed to update package repositories on remote end."
|
err "Failed to update package repositories on remote end."
|
||||||
err "Please make sure you have the required access rights."
|
err "Please make sure you have the required access rights."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! inf_follow "Installing borg on remote end..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" apt-get install -y borgbackup; then
|
if ! inf_follow "Installing borg on remote end..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command ssh -i "$SSH_KEY_FILE" -p "$SSH_PORT" -oStrictHostKeyChecking=no -oBatchMode=yes -l "$SSH_USER" "$SSH_HOST" apt-get install -y borgbackup; then
|
||||||
err "Failed to install borg on remote end."
|
err "Failed to install borg on remote end."
|
||||||
err "Please make sure you have the required access rights"
|
err "Please make sure you have the required access rights"
|
||||||
exit 1
|
exit 1
|
||||||
|
Reference in New Issue
Block a user