For marketers
who love technology
Home » » Setting proxy for bash in debian

Setting proxy for bash in debian

English: Xfce Terminal. on Debian Lenny. 日本語: ...
English: Xfce Terminal. on Debian Lenny. 日本語: Xfce Terminal。Debian Lennyで。 (Photo credit: Wikipedia)

In this post, I will explain you how to configure the default proxy for bash in Debian. I often see questions about this in forums, so I hope it will help. If so, I would love to see links pointing to this article: it will help others find it more easily thanks to a better ranking in Google search. Thanks!

Setting up the proxy globally

You can set the proxy globally in the files:


In this file you can specify the proxy for a given application for instance (see

http_proxy= firefox

For bash

It's possible to specify the proxy in bash directly:

sudo env http_proxy=

Or in your .bashrc profile (not advised as it may not be taken into account by some applications):

export http_proxy=http://username:password@proxyhost:port/ 
export ftp_proxy=http://username:password@proxyhost:port/

For aptitude (apt-get)

If you want to set the proxy for apt, the proper way is to edit /etc/apt/apt.conf and add:

Acquire::http::proxy "";

For pip / easy_install

For pip, you can use the --proxy option to specify a proxy:

pip install toto --proxy "user:password@proxy.server:port"
pip install toto --proxy ""

English: Diagram of an open forward proxy.
English: Diagram of an open forward proxy. (Photo credit: Wikipedia)
But pip sometimes calls files that do not follow the proxy directives. In this case the best way is to position http_proxy environment variable, and use easy_install as an alternative to pip.


You can use ssh through a SOCKS proxy, but you need to install a few tools:

sudo apt-get install connect-proxy
man connect-proxy
vim ~/.ssh/config

In this configuration file, you specify which proxy you want to use for which hosts. For example, on this site, they provide the following configuration sample:

## Outside of the firewall, with HTTPS proxy
  ProxyCommand connect -H %h 443
## Inside the firewall (do not use proxy)
Host *
   ProxyCommand connect %h %p

Note the -S command, that is used for SOCKS proxy (-H) is for HTTP proxies, for example:
ProxyCommand /usr/bin/connect-proxy -4 -S pproxy:port %h %p

SANS institute published a good article about all what you can do with SSH trough a proxy :)

If you have liked this article, please put a link to it on your Google+ profile are any other kind of web site: it will help others find it in the search engines. Thanks!

configuring a proxy in bash terminal for Linux

About Gilles


  1. It's always hard to setting proxy for bash in dabian and it is time consuming for me. You same my day by giving such nice tips and tutorial, It's easy to understand and deep to learn a lot from your post. I want to setup Microleaves proxy dedicated ip for my project and hope i am get success in it. Keep updating and keep helping student like me.

  2. Thanks for this post, I really appriciate. I have read posts, all are in working condition. and I really like your writing style. Keep it up like.
    tray free proxy

  3. Is it possible to write a script in bash which would connect to millions of IPs and would rotate them every few minutes? Like to
    Would be great if you wrote an article about how to do it because I'm still bashing my head in the wall while trying to figure out a solution.

  4. Good article, but if someone would like to know moere about China proxy. check this list

  5. I never ever used Free proxies for my scraping tasks, or when trying to access blocked content from my country. You may never know what kind of people provide them, so it's better to use TOR for unblocking content and staying anonymous and residential proxy networks like this review

  6. if your'e copping sneakers and need decent sneaker proxies, then check out this article

  7. Proxies are highly needed and important and can be used for various reasons. I would recommend reading more about them and about the best proxy providers best proxy providers in the market.