How do I configure proxy and proxy authentication in Linux?

58,600

1 : Open a terminal window and type the following command

sudo gedit /etc/environment

2 : Copy the following lines in your /etc/environment file and modify accordingly.

 http_proxy=http://user:password@proxy:port/    
 https_proxy=http://user:password@proxy:port/    
 ftp_proxy=http://user:password@proxy:port/    
 no_proxy="localhost,127.0.0.1"    
 HTTP_PROXY=http://user:password@proxy:port/    
 HTTPS_PROXY=http://user:password@proxy:port/     
 FTP_PROXY=http://user:password@proxy:port/   
 NO_PROXY="localhost,127.0.0.1"

3 : save your changes and log-out and log-in.

4 : If your apt-get command is still not able to access internet,execute

sudo gedit /etc/apt/apt.conf.d/95proxies

and copy the following lines and modify accordingly

Acquire::http::proxy "http://user:password@proxy:port/";    
Acquire::ftp::proxy "ftp://user:password@proxy:port/";   
Acquire::https::proxy "https://user:password@proxy:port/";

5 : once again save your changes and log-out and log-in.

P.S : You may have to delete /etc/apt/apt.conf.d/environment. It is not a place to store the environment variables. Moreover there is no such file on my system.

Share:
58,600

Related videos on Youtube

gaurav
Author by

gaurav

Updated on September 18, 2022

Comments

  • gaurav
    gaurav over 1 year

    Online there are many post which tell different ways to add proxy in Linux . but i want to know best way add proxy and proxy authentication in Linux specially Linux mint . because i already try /etc/apt/apt.conf to add or /etc/apt/apt.conf.d/environment but my terminal doesn't connect so does Firefox . there are network setting option where we can proxy that also doesn't work.

    • GAD3R
      GAD3R over 7 years
      Are you using .ovpn file?
    • gaurav
      gaurav over 7 years
      @GAD3R no , i don't
    • GAD3R
      GAD3R over 7 years
      can you add the output of cat /etc/apt/apt.conf?
    • gaurav
      gaurav over 7 years
      Acquire::http::proxy "username:password@proxy:port"; same as for https,ftp& sock
  • gaurav
    gaurav over 7 years
    still no connection