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 a n00b when it comes to ssh, sudo and other unix things... so bear with me, here.

i've got a rails website set up and deploying with vlad via ssh already. this works fine. now i need to have my deploy process run a sudo command to restart monit.

i basically just want to run "sudo monit reload" and "sudo monit start my_job_name". but when i have vlad run these commands, i get errors from ubuntu server:

sudo: no tty present and no askpass program specified

I've done some google-searches and most of the answers i've found involve modifying /etc/sudoers to not require a password for the commands i want. i don't like this option, honestly. it seems like a hack / workaround when i should be able to configure my server to correctly ask for a password and have vlad provide the password (after all, vlad supports a ssh_password setting, which i have filled in).

can someone point me in the right direction to configure my vlad script and my ubuntu 10.10 server, to run my sudo command correctly?

share|improve this question

Try this:

set :sudo_flags, sudo_flags << '-S'
set :run_as_sudo, [sudo_cmd, sudo_flags].flatten.compact.join(' ')

For your commands do:

run "#{run_as_sudo} cmd"

It should prompt you for your password at run time.

share|improve this answer
Also, I think it makes sense to have this question on stackoverflow, because people there are more familiar with vlad. – m33lky Nov 2 '11 at 5:45

You can modify /etc/sudoers and remove requiretty option in order to have sudo working when there's no tty available (e.g. from cron jobs, daemons and so on). You don't have to allow passwordless sudo, just remove this option.

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.