Ubuntu – Proxy with authentication in Ubuntu 18.04

18.04networkingPROXY

I have a fresh install of Ubuntu 18.04 and need to configure proxy in a corporate environment which comes with a corporate proxy (I know domain, credentials, proxy server and port).

I copied out proxy url and port from another PC (non linux), and put it inside Firefox in Ubuntu. It asked me for my credentials and after entering them it worked for that Firefox session.

I figured now I can just add that to the Network options in Ubuntu. I chose the manual option in Proxy settings and filled all the protocol options with tested proxy URL and ports. It didn't work.


What I have tried so far:

  1. Inputting username:password@proxyurl and domain\username:password@proxyurl in manual proxy settings for every protocol. Port went to the designated input.
  2. I tried just adding the proxyurl and port in the Manual config of Proxy settings without authorization
  3. Doing the terminal way of export http_proxy="http://username:password@proxyurl:port/" without any success
  4. Setting up cntlm for domain, username, password hash, proxy server with port and rebooting ubuntu, restarting cntlm
  5. Previously tried on Ubuntu Gnome LTS (based off of Ubuntu 16.04 LTS) with all the aforementioned without any success

Question

How can I add a system-wide proxy to Ubuntu 18.04 that works in every app and terminal?

Best Answer

I have been able to solve this issue successfully. For anyone facing the same issues, here is what I did:

Tested on Ubuntu 18.04, 16.04 and CentOS 7


Instructions

  1. Install cntlm (supplied through Virtualbox Shared Folders)
  2. Specifying username, domain, password hash (PassNTLMv2 - obtained with cntlm -H after setting username and domain), proxy server, noproxy, listen (I used the default 3128)
  3. Launching cntlm in bash
  4. Using your DE's network settings to set system-wide proxy (easy in gnome 3) OR specifying http_proxy and https_proxy in /etc/environment to 127.0.0.1:3128 (cntlm's listening port locally)
  5. [Ubuntu] Specifying proxy settings in /etc/apt/apt.conf (e.g. Acquire::http::Proxy "http://127.0.0.1:3128"; for both http and https separately)

Now either open a new terminal window to test connection (wget/apt) or sign out and back in to test system-wide settings.


Setting up with firefox

Firefox however didn't work with the steps above only. Open settings and on the bottom of the General tab there are proxy settings. Just input the address to your local server manually and check the box to use it for every protocol.