Instantly share code, notes, and snippets.

Embed
What would you like to do?
ssh restricted commands
command="./ssh-cmd.bash",no-agent-forwarding,no-port-forwarding,no-pty,no-X11-forwarding ssh-rsa ...KEY... user@host
#!/bin/sh
case "$SSH_ORIGINAL_COMMAND" in
foo)
echo FOO
echo "--> $SSH_ORIGINAL_COMMAND <--"
exec echo do-foo
;;
'bar -v')
echo BAR
echo "--> $SSH_ORIGINAL_COMMAND <--"
exec echo do-bar -v
;;
baz|'baz '*)
echo BAZ
echo "--> $SSH_ORIGINAL_COMMAND <--"
exec echo do-baz ${SSH_ORIGINAL_COMMAND#baz}
;;
fail)
echo FAIL
exec false
;;
*)
echo "command not supported: $SSH_ORIGINAL_COMMAND" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment