3

I'm struggling with running the following command:

 ssh someuser@lab-test "sudo /usr/local/scripts/user.sh add tstt7777 177700007 \"Test User 06\" "

Long story short I need to run the user.sh script with ROOT privlages as someuser from a remote machine. However I do not want someuser to be able to run ANY other commands, open a shell or otherwise have access to the system. The user needs only to run that script with multiple dynamic arguments.

I've handled the public key exchange already, and I've added privlages in sudo:

#Sudo
someuser  ALL = NOPASSWD: /usr/local/scripts/user.sh

But I get the following error:

sudo: sorry, you must have a tty to run sudo

I've looked at the "Command=" function in ssh but my understanding is that this will only run the command specified and won't allow arguments to be passed as indicated in my invocation.

Is there something I'm missing to make my method work via sudo?

Is there a better method that I haven't considered in SSH or BASH?

5

Run visudo and comment out as below:

#Default requiretty
  • I should note that I confirmed this with a mere 'sudo no tty' in google... – anastrophe Sep 27 '11 at 22:19
  • Went with a little more controlled version: Defaults:idm !requiretty – Gray Race Sep 27 '11 at 22:28
1

Simply add the -t ( pseudo-tty )option along with the ssh command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.