#!/bin/bash # /root/.ssh/jarvis-guard.sh.example # SSH Forced Command Guardrail for OpenClaw Jarvis System CMD="$SSH_ORIGINAL_COMMAND" LOGFILE="/var/log/jarvis-ssh.log" echo "[$(date -Iseconds)] USER=$USER SSH_CMD=$CMD" >> "$LOGFILE" # Block destructive filesystem commands if [[ "$CMD" =~ (mkfs|wipefs|blkdiscard|dd\ of=/dev/|shutdown|reboot|poweroff|halt) ]]; then echo "REJECTED: Destruktiver Befehl blockiert." >&2 exit 1 fi # Block unauthorized path modifications if [[ "$CMD" =~ (/root/.ssh|authorized_keys|sudoers|shadow) ]]; then echo "REJECTED: Zugriff auf geschuetzte Systempfade verweigert." >&2 exit 1 fi # Execute allowed command exec /bin/bash -c "$CMD"