I have an ssh user which has limited access on the remote host.
sshd_config for this user looks like this:
Match User testuser
ForceCommand /usr/local/bin/test_script.sh
AllowTcpForwarding no
X11Forwarding no
PermitTunnel no
The user’s only role/permission is to run the /usr/local/bin/test_script.sh, script that expects 2 input parameters. And nothing else.
The script content is:
#!/bin/bash
echo "test me =$1 =$2"
I am calling this script remotely from another linux instance as follows:
sshpass -p '<userPass>' ssh [email protected] << EOF
sudo /usr/local/bin/test_script.sh "input1" "input2"
My problem is that the output of the call above from the remote host is always:
test me = =
The script gets called but the 2 params are never being received by the test_script.sh.
I know is not a problem with the scripts or the way I call them, because if I use a ssh user with full access on the remote host, the 2 parameters are showing up in response message. Unfortunately I cannot us a user with full access, in this case.
Something is wrong with the testuser configurations, but I’m not clear what exactly.
I’ve also tried:
ForceCommand /bin/bash -c "/usr/local/bin/test_script.sh"
in sshd_config .
Also added in visudo:
testuser ALL=(ALL) NOPASSWD: /usr/local/bin/test_script.sh
But no luck.
Any idea how I can configure the testuser to only be allowed to call over ssh the test_script.sh with parameters on the target host?
Thanks
PS: ssh service and/or the whole remote system were restarted after each configuration change.