#!/bin/sh # # Set or get ssh pubic key of # Usage: key [] # # shellcheck source=./includes LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes" jail_name="${1:?}" keyfile="${2:-}" if [ ! -n "${jail_name}" ]; then "${LIBDIR}/bkctld-help" && exit 1 fi jail_path=$(jail_path "${jail_name}") test -d "${jail_path}" || error "${jail_name}: jail is missing." if [ -z "${keyfile}" ]; then if [ -f "${jail_path}/${AUTHORIZED_KEYS}" ]; then cat "${jail_path}/${AUTHORIZED_KEYS}" fi else [ -e "${keyfile}" ] || error "Keyfile ${keyfile} dosen't exist !" cat "${keyfile}" > "${jail_path}/${AUTHORIZED_KEYS}" chmod 600 "${jail_path}/${AUTHORIZED_KEYS}" notice "${jail_name}: update key => ${keyfile}" fi