Created
August 25, 2021 15:55
-
-
Save afresh1/16929acd675e25ff559c01f71dc26a11 to your computer and use it in GitHub Desktop.
A script to use as an SSH ForceCommand that only lets root connect to run rsync in the way FreeNAS/TrueNAS does it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
expect='rsync --server --sender -logDtprze.LsfxC . /' | |
dir="/${SSH_ORIGINAL_COMMAND#$expect}" | |
# Try without compression | |
if [ "$dir" = "/${SSH_ORIGINAL_COMMAND}" ]; then | |
expect='rsync --server --sender -logDtpre.LsfxC . /' | |
dir="/${SSH_ORIGINAL_COMMAND#$expect}" | |
fi | |
if [ "$dir" != "/${SSH_ORIGINAL_COMMAND}" -a -e "$dir" ]; then | |
exec ${SSH_ORIGINAL_COMMAND} -vvv | |
fi | |
set -- ${SSH_CONNECTION} | |
SRC="$1 port $2" | |
DST="$3 port $4" | |
logger -t force_rsync -p auth.warning \ | |
"Invalid rsync command from user ${USER} ${SRC}: [${SSH_ORIGINAL_COMMAND}]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment