Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 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

 
discard

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.