Created
September 17, 2012 21:53
-
-
Save miend/3740018 to your computer and use it in GitHub Desktop.
Simple scriptlet for parsing incoming SSH commands to either reject if they don't match the desired value or else escalate (via SUDO) if they do match
This file contains hidden or 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/bash | |
# Exits if command not rsync. | |
# Escalates to root via sudo if rsync. | |
case "$SSH_ORIGINAL_COMMAND" in | |
*\&*|*\|*|*\;*|*\>*|*\<*|*\!*) | |
exit 1 | |
;; | |
/usr/bin/rsync\ --server\ --sender*) | |
sudo $SSH_ORIGINAL_COMMAND | |
;; | |
*) | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"The intention is for bare-metal rsync backups by non-root user SSH in a secure fashion (i.e.; keypair + IP restriction + command restriction). So backup.company.com can run rsync@whateverhost and pull down everything thusly. (This is for rsnapshot in my home env.)"
~ Logos01