Browse Source

new: [rsync-backup-target] add ``ssh-key get-type IDENT`` to get backup type info

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
pull/1/head
Valentin Lab 4 years ago
parent
commit
d84472a277
  1. 9
      rsync-backup-target/build/src/usr/local/sbin/ssh-admin-cmd-validate
  2. 18
      rsync-backup-target/build/src/usr/local/sbin/ssh-key

9
rsync-backup-target/build/src/usr/local/sbin/ssh-admin-cmd-validate

@ -71,6 +71,15 @@ elif [[ "$SSH_ORIGINAL_COMMAND" =~ ^"ssh-key rm "[a-zA-Z0-9._-]+$ ]]; then
# echo "Would accept: $SSH_ORIGINAL_COMMAND" >&2 # echo "Would accept: $SSH_ORIGINAL_COMMAND" >&2
exec sudo /usr/local/sbin/ssh-key rm "$label" "${ssh_args[@]:2}" exec sudo /usr/local/sbin/ssh-key rm "$label" "${ssh_args[@]:2}"
elif [[ "$SSH_ORIGINAL_COMMAND" =~ ^"ssh-key get-type "[a-zA-Z0-9._-]+$ ]]; then
log "ACCEPTED: $SSH_ORIGINAL_COMMAND"
## Interpret \ to allow passing spaces (want to avoid possible issue with \n)
#read -a ssh_args <<< "${SSH_ORIGINAL_COMMAND}"
ssh_args=(${SSH_ORIGINAL_COMMAND})
# echo "Would accept: $SSH_ORIGINAL_COMMAND" >&2
exec sudo /usr/local/sbin/ssh-key get-type "$label" "${ssh_args[@]:2}"
elif [[ "$SSH_ORIGINAL_COMMAND" =~ ^"request-recovery-key "[a-zA-Z0-9._-]+$ ]]; then elif [[ "$SSH_ORIGINAL_COMMAND" =~ ^"request-recovery-key "[a-zA-Z0-9._-]+$ ]]; then
log "ACCEPTED: $SSH_ORIGINAL_COMMAND" log "ACCEPTED: $SSH_ORIGINAL_COMMAND"

18
rsync-backup-target/build/src/usr/local/sbin/ssh-key

@ -54,6 +54,20 @@ ssh-key-rm() {
} }
ssh-key-get-type() {
local label="$1" ident="$2" key content commentary
key="${RSYNC_KEY_PATH}/backup/$label/$ident.pub"
if ! [ -e "$key" ]; then
echo "Error: key '$ident' not found." >&2
return 1
fi
content=$(cat "$key") || return 1
commentary=${content##* }
printf "%s\n" "${commentary%%@*}"
}
ssh-key-add() { ssh-key-add() {
local label="$1" type="$2" key="$3" email="$4" local label="$1" type="$2" key="$3" email="$4"
@ -127,6 +141,10 @@ case "$1" in
shift shift
ssh-key-ls "$@" ssh-key-ls "$@"
;; ;;
"get-type")
shift
ssh-key-get-type "$@"
;;
*) *)
echo "Unknown command '$1'." echo "Unknown command '$1'."
;; ;;

Loading…
Cancel
Save