www.question-defense.com | Engage: Visit :: Login :: Register
Translate to English Übersetzen Sie zum Deutsch/German Переведите к русскому/Russian Μεταφράστε στα ελληνικά/Greek Vertaal aan het Nederlands/Dutch ترجمة الى العربية/Arabic 中文翻译/Chinese Traditional 中文翻译/Chinese Simplified 한국어에게 번역하십시오/Korean 日本語に翻訳しなさい /Japanese Traduza ao Português/Portuguese Traduca ad Italiano/Italian Traduisez au Français/French Traduzca al Español/Spanish
0

I was recently working on a Perl script that would SSH to another server and run a sudo command on the remote server that was failing. The error that was received is below.

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

The reason for this is an update along the way with sudo locked it down further by adding the below line to /etc/sudoers configuration file.

Defaults requiretty

To allow a remote script to login and run a command via sudo simply comment out that line as shown below.

# Commented out so remote script can login and run a command without a tty
# Defaults requiretty

I would suggest making a comment in the sudoers file along with the actual script that is running just in case there is another systems administrator that is tasked with working on this server at a later date. Now when your script runs it will not throw that error and should be able to run the remote command that was initially required.

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineLinkedInYahoo! Bookmarks
Related posts:
  1. sudo: unable to resolve host I ran in to the weirdest error today.   “sudo: unable...
  2. NGINX – SSL received a record that exceeded the maximum permissible length When configuring NGINX with SSL the configuration stated you could...
  3. Compiling ruby on OS X 10.5: readline.c:703: error: ‘filename_completion_function’ undeclared When compiling Ruby 1.8.6 (in this case, p287) on OS...
  4. Authentication refused: bad ownership or modes for file .ssh/authorized_keys When configuring SSH keys to be able to login to...
  5. TFTP: Error code 1: File not found You may get the below error code when attempting to...

Tags: , , , , , , ,
35 Responses to “sudo: sorry, you must have a tty to run sudo”
  1. seo tools says:

    While I don’t have much else to add to this post, I am certainly grateful that the author took the time to talk about this. I agree with most of what was talked about, and look forward to learning some more from you. Thank you.

    [Reply]

    alex Reply:

    Hello SEO Tools,

    Thanks for taking the time to leave feedback relating to the sudo article.

    Thanks.
    alex

    [Reply]

  2. Rick says:

    solved my problem!

    [Reply]

    alex Reply:

    Hello Rick,

    Good to hear. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  3. Daniel says:

    Thanks for this. I managed to waste quite a bit of time with this problem until I wised up and took a look at the apache log file and saw what was going wrong. Shame this is not mentioned anywhere in the sudo or visudo man pages.

    Daniel

    [Reply]

    alex Reply:

    Hello Daniel,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  4. Wilfred says:

    That’s a good article about sudo: sorry, you must have a tty to run sudo. Thanks for the info.

    [Reply]

    alex Reply:

    Hello Wilfred,

    No problem at all. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  5. dofollow blogs says:

    I was wondering about sudo: sorry, you must have a tty to run sudo. I was looking for this information for a long time. Thanks for this post!

    [Reply]

    alex Reply:

    Hello dofollow,

    No problemo. Thank you for leaving feedback and letting us know that you found the article helpful.

    Thanks.
    alex

    [Reply]

  6. Joe says:

    You can also make security admins happier by limiting the scope of your removal of restrictions by specifying the user who can issue a command with no tty. Rather than removing the default for everyone as mentioned in this post, add the user name as follows

    Defaults:user1 !requiretty

    The ‘!’ means ‘not’ in this situation, and of course ‘user1′ should be your actual user name.

    Joe

    [Reply]

    alex Reply:

    Hello Joe,

    Yeah definitely fair enough I totally agree. The goal of the article (not saying its perrfect :) ) is to accomplish the goal in the easiest manner and without going into to many details with people the above works. If users read these comments I definitely agree with Joe. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  7. Guillermo says:

    Thanks for your post. I run into this problem while using capistrano.

    [Reply]

    alex Reply:

    Hello Guillermo,

    No problem. Thanks for taking the time to leave feedback.

    Thanks.
    alex

    [Reply]

  8. tuni says:

    Thanks

    [Reply]

    alex Reply:

    Hello tuni,

    No problem at all. Thank you for leaving feedback.

    Thanks.
    alex

    [Reply]

  9.  
Leave a Reply