3 ms·
sudo /usr/sbin/$SSH_ORIGINAL_COMMAND By the way: SSH_ORIGINAL_COMMAND is a command like you would give to sh -c, basically a tiny snippet of sh code. Its not a
by blueflow 3y ago
sudo /usr/sbin/$SSH_ORIGINAL_COMMAND
By the way: SSH_ORIGINAL_COMMAND is a command like you would give to sh -c, basically a tiny snippet of sh code. Its not an argument vector! You either need a shell to kind of eval it or parse it with wordexp(3) before you can reliably tell which executable name it refers to.
Mean people might send one starting with '$(' or another expansion. Remember this is valid:
ssh host '$(echo id)'
- mmsc 3y agoWith the following test.sh: #!/bin/bash case "$SSH_ORIGINAL_COMMAND" in *) sudo $SSH_ORIGINAL_COMMAND ;; esac and the ssh-based restriction: command="/tmp/test.sh" $ ssh user@server 'uname > /tmp/123' uname: extra operand ‘>’ Try 'uname --help' for more information. $ ssh user@server 'uname $(ls)' uname: extra operand ‘$(ls)’ Try 'uname --help' for more information.