I am using Fabric to run commands on a remote server. The user with which I connect on that server has some sudo privileges, and does not require a password to use these privileges. When SSH'ing into the server, I can run sudo blah
and the command executes without prompting for a password. When I try to run the same command via Fabric's sudo
function, I get prompted for a password. This is because Fabric builds a command in the following manner when using sudo
:
sudo -S -p <sudo_prompt> /bin/bash -l -c "<command>"
Obviously, my user does not have permission to execute /bin/bash
without a password.
I've worked around the problem by using run("sudo blah")
instead of sudo("blah")
, but I wondered if there is a better solution. Is there a workaround for this issue?