Reading passwords escape-safe now

This commit is contained in:
Enrico Ludwig 2024-05-14 12:25:03 +02:00
parent a1a67eca33
commit 6e5f96f7a9

View File

@ -35,7 +35,7 @@ DEBUG=0 # Set to 1 to enable debug mode
BACKUP_REPO="Backups/$(hostname | tr '[:lower:]' '[:upper:]')" # Repository path on the backup server BACKUP_REPO="Backups/$(hostname | tr '[:lower:]' '[:upper:]')" # Repository path on the backup server
BACKUP_ENCRYPTION="none" # Encryption method for the backup repository (default: none) BACKUP_ENCRYPTION="none" # Encryption method for the backup repository (default: none)
BACKUP_PASSPHRASE="example" # Make sure to change this to a secure passphrase (will be ignored if encryption is set to none) BACKUP_PASSPHRASE='example' # Make sure to change this to a secure passphrase (will be ignored if encryption is set to none)
BACKUP_DIRS="/etc /var/log /home" # Directories to backup, separated by space BACKUP_DIRS="/etc /var/log /home" # Directories to backup, separated by space
BACKUP_LABEL_PREFIX="BACKUP-" # Prefix for the backup label BACKUP_LABEL_PREFIX="BACKUP-" # Prefix for the backup label
BACKUP_CRON_SCHEDULE="0 3 * * *" # Cron schedule for backups (default: daily at 3:00 AM) BACKUP_CRON_SCHEDULE="0 3 * * *" # Cron schedule for backups (default: daily at 3:00 AM)
@ -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_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_PORT="22" # SSH port of the backup server (default: 22)
SSH_USER="root" # SSH user on the backup server SSH_USER="root" # SSH user on the backup server
SSH_PASSWORD="12345678" # Only required for copying the ssh key to the backup server SSH_PASSWORD='12345678' # Only required for copying the ssh key to the backup server
SSH_KEY_NAME="borgmatic" SSH_KEY_NAME="borgmatic"
SSH_KEY_TYPE="ed25519" # SSH key type (e.g. rsa, dsa, ecdsa, ed25519), default: ed25519 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}" SSH_KEY_FILE="/root/.ssh/${SSH_KEY_NAME}_${SSH_KEY_TYPE}"
@ -680,7 +680,7 @@ 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."
wrn "This is required to enable passwordless ssh login for backups." wrn "This is required to enable passwordless ssh login for backups."
read -s -p "Password: " SSH_PASSWORD read -r -s -p "Password: " SSH_PASSWORD
echo "" echo ""
fi fi
@ -826,7 +826,7 @@ if [ -z "$BACKUP_PASSPHRASE" ] && [ "$BACKUP_ENCRYPTION" != "none" ]; then
wrn "Please enter the passphrase for the backup encryption." wrn "Please enter the passphrase for the backup encryption."
wrn "This is required to encrypt your backups." wrn "This is required to encrypt your backups."
read -s -p "Passphrase: " BACKUP_PASSPHRASE read -r -s -p "Passphrase: " BACKUP_PASSPHRASE
echo "" echo ""
fi fi
@ -837,7 +837,7 @@ if [ "$BACKUP_ENCRYPTION" == "none" ]; then
exit 1 exit 1
fi fi
else else
if ! inf_follow "Setting up borgmatic repository with encryption..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command BORG_PASSPHRASE=$BACKUP_PASSPHRASE /root/.local/pipx/venvs/borgmatic/bin/borgmatic init --make-parent-dirs --encryption=$BACKUP_ENCRYPTION; then if ! inf_follow "Setting up borgmatic repository with encryption..." "\e[1;32mOK\e[0m" "\e[1;31mFAILED\e[0m" run_command BORG_PASSPHRASE="$BACKUP_PASSPHRASE" /root/.local/pipx/venvs/borgmatic/bin/borgmatic init --make-parent-dirs --encryption="$BACKUP_ENCRYPTION"; then
err "Failed to set up borgmatic repository with encryption." err "Failed to set up borgmatic repository with encryption."
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