I am trying to execute a local script on remote server via ssh using keytab authentication. I am able to connect to remote via ssh as sachin(user who gets the ticket) and then I am spawning a bash process as another user, remoteuser. So far so good. Here's the command
ssh -q -o BatchMode=yes -o StrictHostKeyChecking=no -l sachin sachin@remote_host 'sudo -u remoteuser /bin/bash' < ./hello.sh
Problem starts when I am trying to pass an argument to hello.sh. I tried the following
ssh -q -o BatchMode=yes -o StrictHostKeyChecking=no -l sachin sachin@remote_host 'sudo -u remoteuser /bin/bash' < ./hello.sh "hello"
I get
/bin/bash: hello: Permission denied.
But without parameters script is executed as remoteuser. So, I don't think any special permission is required.
hello.sh is a simple shell script.
#!/bin/bash
echo $1
Any Idea what's wrong?