From 094fc441e10d369549ae4062c23676a0a3783d7e Mon Sep 17 00:00:00 2001 From: Enrico Ludwig Date: Tue, 14 May 2024 12:07:35 +0200 Subject: [PATCH] chore: Improve ssh key copy process and remote communication --- borgmatic_setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/borgmatic_setup.sh b/borgmatic_setup.sh index 64f402f..d55371d 100755 --- a/borgmatic_setup.sh +++ b/borgmatic_setup.sh @@ -45,7 +45,7 @@ BORGMATIC_CONFIG_FILE="/etc/borgmatic/config.yaml" # Path to the borgmatic confi SSH_HOST="127.0.0.1" # Hostname or IP address of the backup server SSH_PORT="22" # SSH port of the backup server (default: 22) SSH_USER="root" # SSH user on the backup server -SSH_PASSWORD="12345678" # Only required for ssh-copy-id +SSH_PASSWORD="12345678" # Only required for copying the ssh key to the backup server SSH_KEY_NAME="borgmatic" SSH_KEY_TYPE="ed25519" # SSH key type (e.g. rsa, dsa, ecdsa, ed25519), default: ed25519 SSH_KEY_FILE="/root/.ssh/${SSH_KEY_NAME}_${SSH_KEY_TYPE}" @@ -686,7 +686,7 @@ if ! inf_follow "Checking if ssh key is already present on $SSH_HOST..." "\e[1;3 echo "" 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" -oStrictHostKeyChecking=no -oBatchMode=yes "$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 sudo sshpass -p "$SSH_PASSWORD" ssh -oStrictHostKeyChecking=no -oBatchMode=yes -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < "$SSH_KEY_FILE"; then err "Failed to copy ssh key to $SSH_HOST." 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."