1

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?

2 Answers 2

0

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.

1
  • Also, I think it makes sense to have this question on stackoverflow, because people there are more familiar with vlad.
    – m33lky
    Nov 2, 2011 at 5:45
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .