From 80868d96967c963a8f2b78731f83bcd90762a568 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 27 Nov 2024 05:52:42 +0100 Subject: [PATCH] Force creation of an ssh key for backups --- scripts/Common/OS/backup.fish | 3 ++- scripts/lib/restoration.fish | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Common/OS/backup.fish b/scripts/Common/OS/backup.fish index d0760dfa..eb1c5d6e 100644 --- a/scripts/Common/OS/backup.fish +++ b/scripts/Common/OS/backup.fish @@ -19,6 +19,7 @@ function backupAction -V dir read -xP "Please specify the host name of the SSH server: " VALHALLA_BACKUP_SERVER read -xP "Please specify the port of the SSH server (default 22): " VALHALLA_BACKUP_SERVER_PORT read -xP "Please specify the name of the user to log in to the SSH server: " VALHALLA_BACKUP_SERVER_USER + read -xP "Please specify the path to the key file for logging in to the SSH server: " VALHALLA_BACKUP_SERVER_KEY if [ -z "$VALHALLA_BACKUP_SERVER_PORT" ] set -x VALHALLA_BACKUP_SERVER_PORT 22 @@ -33,7 +34,7 @@ function backupAction -V dir echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication." echo echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)" - echo "ssh -o PasswordAuthentication=no -p $VALHALLA_BACKUP_SERVER_PORT $VALHALLA_BACKUP_SERVER true" + echo "sudo ssh -o PasswordAuthentication=no -i $(string escape -- "$VALHALLA_BACKUP_SERVER_KEY") -p $VALHALLA_BACKUP_SERVER_PORT $VALHALLA_BACKUP_SERVER true" read -P "Press enter once you're done: " echo end diff --git a/scripts/lib/restoration.fish b/scripts/lib/restoration.fish index efb82393..0a414e28 100644 --- a/scripts/lib/restoration.fish +++ b/scripts/lib/restoration.fish @@ -62,7 +62,7 @@ function runRestorationCommand set -a args -p $VALHALLA_BACKUP_SERVER_PORT end - ssh $args "$VALHALLA_BACKUP_SERVER" (string escape -- $argv) + sudo ssh -i $(string escape -- "$VALHALLA_BACKUP_SERVER_KEY") $args "$VALHALLA_BACKUP_SERVER" (string escape -- $argv) end end