Added first version
This commit is contained in:
parent
38b0fa8a52
commit
da6cdadf6c
13
README.md
13
README.md
@ -1 +1,12 @@
|
||||
# rsnapshothelper
|
||||
# rsnapshothelper
|
||||
combination of:
|
||||
- https://serverfault.com/questions/749474/ssh-authorized-keys-command-option-multiple-commands
|
||||
- https://www.virtono.com/community/tutorial-how-to/restrict-executable-ssh-commands-with-authorized-keys/
|
||||
|
||||
add your public key on target server like: command="/root/rsnapshothelper.sh" ...........
|
||||
|
||||
Can be used for more than just rsnapshot.
|
||||
|
||||
Could be improved by reading a ini, yaml, use regex, etc. Feel free!
|
||||
|
||||
Have fun
|
24
rsnapshothelper.sh
Normal file
24
rsnapshothelper.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
if [ -n "$SSH_ORIGINAL_COMMAND" ]
|
||||
then
|
||||
#echo "$(/bin/date): $SSH_ORIGINAL_COMMAND" >> $HOME/rsnapshothelper.log
|
||||
case "$SSH_ORIGINAL_COMMAND" in
|
||||
"rsync --server --sender -vlogDtprRe.iLsfxC --numeric-ids . /opt")
|
||||
echo "$(/bin/date): OK: $SSH_ORIGINAL_COMMAND" >> $HOME/rsnapshothelper.log
|
||||
exec $SSH_ORIGINAL_COMMAND
|
||||
;;
|
||||
"rsync --server --sender -vlogDtprRe.iLsfxC --numeric-ids . /etc")
|
||||
echo "$(/bin/date): OK: $SSH_ORIGINAL_COMMAND" >> $HOME/rsnapshothelper.log
|
||||
exec $SSH_ORIGINAL_COMMAND
|
||||
;;
|
||||
"mysqldump --all-databases")
|
||||
echo "$(/bin/date): OK: $SSH_ORIGINAL_COMMAND" >> $HOME/rsnapshothelper.log
|
||||
exec $SSH_ORIGINAL_COMMAND
|
||||
;;
|
||||
*)
|
||||
echo "$(/bin/date): VIOLATION: $SSH_ORIGINAL_COMMAND" >> $HOME/rsnapshothelper.log
|
||||
echo "Access denied"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
Loading…
Reference in New Issue
Block a user