How to remove internet proxy settings for apt-get?

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
werunom

How to remove internet proxy settings for apt-get?

Post by werunom »

Hi!

New to linux and mint! I was trying to configure the internet network connections settings so that my laptop (Mint 17.3) is able to connect through proxy in my university. After seeing several articles (espeically used this article), I realised I have to do two things -
(1) Set the proxy settings in /etc/environment file
(2) create a file called 95proxies in /etc/apt/apt.conf.d/ with the proxy settings

I did these and the computer was able to connect to internet through proxy. But when I connect to my home wifi, I realised the linux mint update manager is not able to check for updates as it is still trying to connect through proxies. For example, it shows - Failed to fetch http://archive.ubuntu.com/ubuntu/dists/ ... elease.gpg Unable to connect to <my university proxy settings>

To revert the changes,
(1) I went to /etc/environment file and commented out the entered lines (I commented by adding "#" at the beginning)
(2) I renamed 95proxies file to some junk name in /etc/apt/apt.conf.d/
I thought after restarting the linux, the default proxy settings would be applicable. But sadly it is not happening.

So, can anyone please tell me the following -
(a) how to revert the changes so that apt-get works fine without any additional proxy settings
(b) is there an easy way to keep shuffling between different proxy settings for the system? The network settings in the system settings does not apply it system wide.

Thanks for your help and time!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
karlchen
Level 23
Level 23
Posts: 18228
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: How to remove internet proxy settings for apt-get?

Post by karlchen »

Hello, werunom.

Preface:
I do not use any file named 95proxies in the folder /etc/apt/apt.conf.d. Instead I use a file named apt.conf in the folder /etc/apt.
Yet, telling from the article that you linked, too, the content of your /etc/apt/apt.conf.d/95proxies and my /etc/apt/apt.conf are equivalent. - So, different filename and location, same effect.
Therefore I am confident that my steps to switch on the proxy and off again will work for you as well.

Note:
I have created a copy of the file /etc/apt/apt.conf holding the enabled proxy settings under the filename of /etc/apt/apt.conf.bak. It is important to know. Else the steps to switch on the proxy do not make sense.
I have configured the systemwide proxy settings through the Network Manager. This allows me to switch it on (Manual) and off (None).


Switching off the proxy systemwide
  1. Switch off proxy in Network Manager
    Control Panel => Network => Proxy: off => Systemwide
    => switches off /etc/apt/apt.conf proxy settings as well by removing proxy settings from /etc/apt/apt.conf automatically
  2. Switch off .wgetrc
    mv ~/.wgetrc ~/.wgetrc.bak
    (Note: if you do not have a .wgetrc file with proxy settings in it, skip this step)
  3. Switch off Synaptic proxy settings
    sudo -i
    cd .synaptic
    gedit synaptic.conf
    change useProxy "1"; => useProxy "0";
  4. reboot
  5. Stop nctlm
    sudo /etc/init.d/cntlm stop
    (Note: In case you do not use the local proxy software cntlm, skip this step)

Switching on the proxy systemwide
  1. Switch on proxy in Network Manager
    Control Panel => Network => Proxy: Manual => Systemwide
    => switches on /etc/apt/apt.conf proxy settings, but incorrectly here
    therefore restore original file: cp apt.conf.bak apt.conf
  2. Switch on .wgetrc
    mv ~/.wgetrc.bak ~/.wgetrc
    (Note: if you do not need a .wgetrc file with proxy settings in it, skip this step)
  3. Switch on Synaptic proxy settings
    sudo -i
    cd .synaptic
    gedit synaptic.conf
    change useProxy "0"; => useProxy "1";
  4. Restore original apt.conf with correct proxy settings in it
    cd /etc/apt
    sudo cp apt.conf.bak apt.conf # proxy entries!
    (same as above under #1, restoring once is enough.)
  5. Reboot
I am pretty confident there may be a more elegant and a more convenient way of switching between proxy and no-proxy, but this is what works for me.
(Same procedure used on Linux Mint 13 and on Ubuntu 14.04.)

HTH,
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 792 days now.
Lifeline
werunom

Re: How to remove internet proxy settings for apt-get?

Post by werunom »

Karlchen,

Thanks for the detailed instructions! Appreciate you taking time and doing this.

Since I do not have the files, the point 2 and 5 are not relevant to me. I checked the synaptic file you mentioned in 3; it did not have the entry you mentioned. That leaves only point 1.
As I already mentioined, I had proxy settings entry in /etc/apt/apt.conf.d/95proxies file and /etc/environment file. To connect to internet automatically (without proxy), I had done the following -
> renamed 95proxies file to some junk name
> commented the environment file (by appending # at the beginning of each line)

With all these, I was not able to make update-manager connect the mirrors for checking update. So, I tried the following -
> moved the renamed 95proxies outside apt folder (to some irrelevant place)
> instead of just commenting, I deleted the commented proxy entries in environment file.

After all these, I was able to connect the update-manager to internet.

Thanks again for your help! Bit surprised why there is no single place setting for making proxy changes instead of making it for everything.
Locked

Return to “Networking”