I have custom Drush commands that contain shell commands with 'sudo' included. This results in an error when calling with remote alias to execute on remote instance:

drush @remote-alias custom-command-with-sudo

From research in google.com, I understand there is not tty session loaded when doing ssh user@ssh-server causing the error:

sudo: no tty present and no askpass program specified

Can I configure drush to include -t flag when its doing ssh -t user@ssh-server. I understand this will load tty session and solve problem, am i wrong?...in short, how do you best overcame this issue? Thank you

UPDATE: I followed instructions from similar question referred by Clive

  1. Added following line in .drush/drushrc.php:

    $options['ssh-options'] = '-o PasswordAuthentication=no -i $HOME/.ssh/id_rsa/lamp_vbox';
  2. Then I run in debug mode by adding --debug and this is what it shows:

Calling proc_open(ssh -o PasswordAuthentication=no -i /Users/owner/.ssh/id_rsa/lamp_vbox margots@lamp-vbox 'COLUMNS=179 drush --debug --uri=dev-metronic --root=/home/websites/dev/metronic --verbose deploy-asset '\''@dev-metronic'\'' --ver=0.3 --asset=metronic --env=dev 2>&1' 2>&1); Starting Drush preflight. [0.06 sec, 1.51 MB]

From the log, I conclude that the settings are being passed, however. I still get the error, so I wonder what could be the problem and how to solve it.

I'm using: Mac 10.9, Drush Version : 7.0-dev

  • I think I recall seeing a similar question here once upon a time with an answer that suggested there wasn't a way to pass custom ssh flags...or maybe it was the other way round. I'll see if I can dig it out
    – Clive
    Oct 23, 2014 at 17:16
  • Ah it was the other way around, this should help
    – Clive
    Oct 23, 2014 at 17:17
  • thank you Clive. It doesn't seem to work. I am updating the question with instructions of the proposed solution
    – latvian
    Oct 23, 2014 at 20:34

1 Answer 1


This may not be solution for everyone, but it worked in my situation because i could change settings at the remote instance. I followed the following instruction and turned on NOPASSWORD, which is adding the following line into sudoers file:

# Members of the admin group may gain root privileges
%admin  ALL=(ALL) ALL

Afterwards, my custom drush commands with sudo works on the remote instance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.