I am trying to run the following command:

sudo git pull;

I get the following error:

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

The command is being run from a nodejs server using child_process and exec.

I have looked at other questions and sites that try and solve this error but none of the solutions ie editing /etc/sudoers and using ssh -t work.

I do not have root access and am therefore using sudo in the command.

I am running a basic Amazon EC2 Linux 64bit instance.

  • What did you try to edit /etc/sudoers with visudo? How about ssh -t -t ...?
    – quanta
    Oct 31, 2011 at 12:19
  • @quanta - I tried to comment out the Default requiretty.
    – Kit
    Oct 31, 2011 at 13:07
  • Did you try ssh -t -t...?
    – quanta
    Oct 31, 2011 at 14:55

1 Answer 1


Check your sudoers file (or have the administrator verify it). It contains something that looks like this:

Default requiretty

(Default can also just be a group, easier to just search for requiretty)

The quick and easy is to comment this out, and this will resolve that problem. You can also set it with !requiretty for the specific command.

You can also try calling sudo with --session-command to overcome this

  • Hi. I can only open /etc/sudoers as read only and cannot save any changes. Any ideas?
    – Kit
    Oct 31, 2011 at 13:06
  • This is an EC2 instance. I've never used one from the perspective of deploying/managing a VM on there yet, but I'm assuming there's some sort of console interface. If you try from there, you should be assigned a TTY so you can get going. I'm assuming here that you are an administrator but you simply don't have the password. I don't feel like assisting in trying to do things you don't have permission to do ;)
    – sandroid
    Oct 31, 2011 at 13:19
  • 2
    This file is always read-only. You must use visudo to edit sudoers file.
    – oker
    Oct 31, 2011 at 13:37
  • visudo or not, he has no root access, and it seems he can't run commands with sudo, so he's still SOL. You're right though, I was assuming (fatal error) that he was editing it with visudo, as it's very ill advised to do otherwise
    – sandroid
    Oct 31, 2011 at 14:04
  • @oker I still cant seem to save the edits when I use visudo. Any ideas?
    – Kit
    Oct 31, 2011 at 14:07

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.