mirror of https://github.com/digint/btrbk
btrbk-verify: allow ssh-user without ssh-identity
Required e.g. if a ssh-agent is already running, and we want to set user=root for rsync.pull/427/head
parent
bef13275d3
commit
d554afab10
|
@ -107,8 +107,8 @@ options:
|
||||||
--ignore-xattrs ignore xattrs when verifying subvolumes
|
--ignore-xattrs ignore xattrs when verifying subvolumes
|
||||||
--ssh-identity FILE override ssh_identity from btrbk.conf(5) with FILE,
|
--ssh-identity FILE override ssh_identity from btrbk.conf(5) with FILE,
|
||||||
and clear all other ssh_* options (use with --ssh-user)
|
and clear all other ssh_* options (use with --ssh-user)
|
||||||
--ssh-user USER override ssh_user from btrbk.conf(5) with USER
|
--ssh-user USER override ssh_user from btrbk.conf(5) with USER, and
|
||||||
(only in conjunction with --ssh-identity)
|
clear all other ssh_* options(use with --ssh-identity)
|
||||||
--ssh-agent start ssh-agent(1) and add identity
|
--ssh-agent start ssh-agent(1) and add identity
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
@ -157,7 +157,6 @@ while [[ "$#" -ge 1 ]]; do
|
||||||
;;
|
;;
|
||||||
--ssh-identity)
|
--ssh-identity)
|
||||||
# use different ssh identity (-i option) for rsync rsh.
|
# use different ssh identity (-i option) for rsync rsh.
|
||||||
# if set, ssh_user defaults to root.
|
|
||||||
# NOTE: this overrides all btrbk ssh_* options
|
# NOTE: this overrides all btrbk ssh_* options
|
||||||
ssh_identity="$2"
|
ssh_identity="$2"
|
||||||
shift
|
shift
|
||||||
|
@ -267,11 +266,14 @@ rsync_rsh()
|
||||||
local rsh_match="(.*) ([a-z0-9_-]+)@([a-zA-Z0-9.-]+)$"
|
local rsh_match="(.*) ([a-z0-9_-]+)@([a-zA-Z0-9.-]+)$"
|
||||||
|
|
||||||
if [[ -z "$rsh" ]]; then
|
if [[ -z "$rsh" ]]; then
|
||||||
echo
|
return
|
||||||
elif [[ -n "$ssh_identity" ]]; then
|
elif [[ -n "$ssh_user" ]] || [[ -n "$ssh_identity" ]]; then
|
||||||
# override btrbk.conf from command line arguments
|
# override btrbk.conf from command line arguments
|
||||||
log_debug "Overriding all ssh_* options from btrbk.conf"
|
log_debug "Overriding all ssh_* options from btrbk.conf"
|
||||||
echo "ssh -q -i $ssh_identity -l $ssh_user"
|
local cmd="ssh -q"
|
||||||
|
[[ -n "$ssh_identity" ]] && cmd="$cmd -i '$ssh_identity'"
|
||||||
|
[[ -n "$ssh_user" ]] && cmd="$cmd -l '$ssh_user'"
|
||||||
|
echo "$cmd"
|
||||||
elif [[ $rsh =~ $rsh_match ]]; then
|
elif [[ $rsh =~ $rsh_match ]]; then
|
||||||
echo "${BASH_REMATCH[1]} -l ${BASH_REMATCH[2]}"
|
echo "${BASH_REMATCH[1]} -l ${BASH_REMATCH[2]}"
|
||||||
else
|
else
|
||||||
|
@ -327,10 +329,6 @@ exit_trap_action()
|
||||||
[[ $verbose -gt 0 ]] && tlog_print
|
[[ $verbose -gt 0 ]] && tlog_print
|
||||||
}
|
}
|
||||||
|
|
||||||
# restrictions from rsync_rsh():
|
|
||||||
[[ -z "$ssh_identity" ]] && [[ -n "$ssh_user" ]] && print_usage 2
|
|
||||||
[[ -n "$ssh_identity" ]] && [[ -z "$ssh_user" ]] && print_usage 2
|
|
||||||
|
|
||||||
# start ssh-agent(1)
|
# start ssh-agent(1)
|
||||||
[[ -n "$ssh_start_agent" ]] && start_ssh_agent
|
[[ -n "$ssh_start_agent" ]] && start_ssh_agent
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue