Compare commits

...

2 Commits

View File

@ -18,7 +18,18 @@ log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$level] $*" | tee -a "$LOG_FILE" echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$level] $*" | tee -a "$LOG_FILE"
} }
log info "Received SSH_ORIGINAL_COMMAND: $SSH_ORIGINAL_COMMAND" logO() {
local level="${1^^}" # convert to uppercase
shift
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$level] $*" >>"$LOG_FILE"
}
logO info "Received SSH_ORIGINAL_COMMAND: $SSH_ORIGINAL_COMMAND"
if [[ "${SSH_ORIGINAL_COMMAND:-}" == "scp -t $ALLOWED_PATH" ]]; then
eval "$SSH_ORIGINAL_COMMAND"
exit
fi
# Ensure the variable is set # Ensure the variable is set
if [[ -z "${SSH_ORIGINAL_COMMAND:-}" ]]; then if [[ -z "${SSH_ORIGINAL_COMMAND:-}" ]]; then
@ -88,8 +99,7 @@ status)
podman images podman images
;; ;;
scp) scp)
log info "Accepting scp upload to $ALLOWED_PATH" log error "Invalid scp upload path: $args"
[[ "${args}" == "-t $ALLOWED_PATH" ]] && eval "$SSH_ORIGINAL_COMMAND" || log error "Invalid scp upload path: $args"
;; ;;
*) *)
log error "Unknown command: $command" log error "Unknown command: $command"