Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to enable secure SSH features #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ On macOS, it has a few disadvantages compared to Time Machine - in particular it
After 365 days keep one backup every 30 days.
--no-auto-expire Disable automatically deleting backups when out of space. Instead an error
is logged, and the backup is aborted.
--secure-ssh Enables secure SSH features.

## Features

Expand Down
14 changes: 12 additions & 2 deletions rsync_tmbackup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fn_display_usage() {
echo " After 365 days keep one backup every 30 days."
echo " --no-auto-expire Disable automatically deleting backups when out of space. Instead an error"
echo " is logged, and the backup is aborted."
echo " --secure-ssh Enables secure SSH features."
echo ""
echo "For more detailed help, please see the README file:"
echo ""
Expand Down Expand Up @@ -279,6 +280,7 @@ LOG_DIR="$HOME/.$APPNAME"
AUTO_DELETE_LOG="1"
EXPIRATION_STRATEGY="1:1 30:7 365:30"
AUTO_EXPIRE="1"
SECURE_SSH="0"

RSYNC_FLAGS="-D --numeric-ids --links --hard-links --one-file-system --itemize-changes --times --recursive --perms --owner --group --stats --human-readable"

Expand Down Expand Up @@ -321,6 +323,9 @@ while :; do
--no-auto-expire)
AUTO_EXPIRE="0"
;;
--secure-ssh)
SECURE_SSH="1"
;;
--)
shift
SRC_FOLDER="$1"
Expand Down Expand Up @@ -543,13 +548,18 @@ while : ; do
fn_log_info "From: $SSH_SRC_FOLDER_PREFIX$SRC_FOLDER/"
fn_log_info "To: $SSH_DEST_FOLDER_PREFIX$DEST/"

SSH_FLAGS=""
if [[ $SECURE_SSH == "0" ]]; then
SSH_FLAGS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
fi

CMD="rsync"
if [ -n "$SSH_CMD" ]; then
RSYNC_FLAGS="$RSYNC_FLAGS --compress"
if [ -n "$ID_RSA" ] ; then
CMD="$CMD -e 'ssh -p $SSH_PORT -i $ID_RSA -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
CMD="$CMD -e 'ssh -p $SSH_PORT -i $ID_RSA $SSH_FLAGS'"
else
CMD="$CMD -e 'ssh -p $SSH_PORT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
CMD="$CMD -e 'ssh -p $SSH_PORT $SSH_FLAGS'"
fi
fi
CMD="$CMD $RSYNC_FLAGS"
Expand Down