2

I am using Ubuntu WSL on Windows 10. How to configure HTTP proxy with authentication on it?

0

cntlm proxy for NTLM authentication

I am assuming your proxy requires a NTLM based user authentication, which will not work with the credentials specified in $HTTP_PROXY.

Install cntlm proxy

The default way of installing the proxy would to type in sudo apt-get install cntlm, but without any proxy this will obviously fail. So you need to manually download the package cntlm_0.92.3-1ubuntu1_amd64.deb and copy into WSL instance.

Install the package with

$ sudo dpkg -i cntlm_0.92.3-1ubuntu1_amd64.deb

Configure cntlm proxy

The cntlm proxy requires proper NTLM-Proxy configuration in /etc/cntlm.conf:

# /etc/cntlm.con
Domain      Domain
Username    username
Proxy       1.2.3.4:5678
NoProxy     localhost, 127.0.0.*, 10.*, 192.168.*
Listen      3128

This is the minimal required configuration for cntlm. You can test the cntlm with the commands:

$ cntlm -M http://www.google.de
cntlm: Starting cntlm version 0.92.3 for LITTLE endian

cntlm: Proxy listening on 127.0.0.1:3128

cntlm: Workstation name used: hostname

Password:

If the authentication works, you can generate hashes for the authentication:

$ cntlm -H                   
cntlm: Starting cntlm version 0.92.3 for LITTLE endian

cntlm: Proxy listening on 127.0.0.1:3128

cntlm: Workstation name used: somehost

cntlm: Using following NTLM hashes: NTLMv2(1) NT(0) LM(0)

Password: 
PassLM          123456789ABCDEF123456789ABCDEF12
PassNT          123456789ABCDEF123456789ABCDEF12
PassNTLMv2      123456789ABCDEF123456789ABCDEF12    # Only for user 'username', domain 'Domain'
cntlm: Terminating with 0 active threads

Add the three hashes PassLM, PassNT and PassNTLMv2 to /etc/cntlm.conf. Then you can activate the proxy via systemd:

    $ sudo systemctl start cntlm

Now the proxy should listen on your localhost at port 3128.

Configure proxy

Now you can configure the proxy as described in this post but use:

$ export http_proxy=http://localhost:3128/
$ export https_proxy=http://localhost:3128/
-1

From your bash shell:

export http_proxy=http://[username]:[password]@[proxy-webaddress]:[port]

and possibly

export https_proxy=https://[username]:[password]@[proxy-webaddress]:[port]

Username and password are often Windows domain credentials. If the password contains any special characters, you may need to escape the special characters with a backslash to protect them from the shell. For example, if your Windows account is "gomer" with a password of "Pea$1rzz", and your proxy server is bluecoat.acme.com on port 8080, then you would say

export http_proxy=http://gomer:Pea\$1rzz@bluecoat.acme.com:8080
export https_proxy=https://gomer:Pea\$1rzz@bluecoat.acme.com:8080

echo $http_proxy
echo $https_proxy 

should show the correct credentials. You'll need to do this for each shell. So, if you're wanting to do some work with apt, it may be more convenient to open a root shell

sudo bash

before setting your proxies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.