Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm struggling with running the following command:

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

Long story short I need to run the 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:

someuser  ALL = NOPASSWD: /usr/local/scripts/

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?

share|improve this question
up vote 5 down vote accepted

Run visudo and comment out as below:

#Default requiretty
share|improve this answer
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

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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