Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 am using fabric to deploy a project and have run into an issue:

fabric does not currently (as far as I'm aware) have the ability to specify options to it sudo command, therefore I cannot use sudo -E to use the local users proxy settings.

How can I go about setting the proxy settings for root.

This needs to be via command line as I'm working on a server box withou a GUI.

share|improve this question
did you try setting it in the sudo command in the fabfile? fabric should still invoke the command with bash -c. something like this on the server: sudo bash -c 'http_proxy=proxyserver blah' – Jay _silly_evarlast_ Wren Feb 24 '13 at 1:19

I don't know if this can help you but I use tsocks for socks proxies like Tor

Install the latest version of tor and tsocks sudo apt-get install tor tsocks

Edit the tsocks configuration file sudo gedit /etc/tsocks.conf so the last few lines should be :

server =
# Server type defaults to 4 so we need to specify it as 5 for this one
server_type = 5
# The port defaults to 1080 but I've stated it here for clarity 
server_port = 9050

and execute any command with tor proxy tsocks sudo apt-get update for example .

share|improve this answer

Just for reference' sake. Fabric perfectly allows the sudo command. From the docs

fabric.operations.sudo(command, shell=True, pty=True, combine_stderr=None, user=None, quiet=False, warn_only=False, stdout=None, stderr=None, group=None)

Here is the example from the docs.

sudo("mkdir /var/www/new_docroot", user="www-data")
sudo("ls /home/jdoe", user=1001)
result = sudo("ls /tmp/")
with settings(sudo_user='mysql'):
    sudo("whoami") # prints 'mysql'

By the way, nice you are using Fabric. It is a good deployment tool.

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.