CentOS 5 Configuration Tweak for sudo

Posted by Scott on Feb 17th, 2008

I recently updated my Rails deployment server from CentOS 4 to CentOS 5, and immediately ran into the following error when deploying my apps using vlad:

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

Thus apache wasn’t being restarted after my mongrel instances. It turns out that RHEL/CentOS 5 includes added restrictions in its default sudo configuration. Simply comment out the following line in /etc/sudoers:

#Defaults requiretty

to resolve the problem.

5 Responses

  1. Alex Le Says:

    Excellent!
    Works as a charm for me. Thanks!

  2. Rick Says:

    Another way around this is to modify your Capistrano setup rather than /etc/sudoers on the deployment target. If you look in the Capistrano recipes (on my Mac it’s in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/capistrano-2.0.0/lib/capistrano/recipes.rb), there’s a note in there about a setting to turn off “sudo” in favor of “run”. So in your application’s deploy.rb (for a rails app it’s app_dir/config/deploy.rb), you can just put in the line:

    set :use_sudo, false

    This worked for me on a fairly vanilla RHEL 5 deployment target from a Mac OS Leopard dev machine. Probably would work on CentOS as well.

  3. siby Says:

    Thanks Man, I was struck by this for 5 hours.

  4. Arno Smit Says:

    Or even easier.

    add the following to your deploy.rb file

    default_run_options[:pty] = true

  5. Vidya Says:

    Thanks!!! It helped me.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Blog Badges



[FSF Associate Member]

Archives