Software & AppsOperating SystemLinux

Configuring HTTP Proxy with Authentication on Ubuntu WSL: A Guide for Windows 10 Users

Ubuntu 12

In this guide, we will walk you through the process of configuring an HTTP proxy with authentication on Ubuntu Windows Subsystem for Linux (WSL) for Windows 10 users. This can be particularly useful when you’re working behind a corporate firewall and need to configure proxy settings for your Ubuntu WSL instance. We’ll be using the cntlm proxy for this purpose.

Quick Answer

To configure an HTTP proxy with authentication on Ubuntu WSL for Windows 10 users, you can use the cntlm proxy. Install the cntlm package, configure it with your proxy server details, generate authentication hashes, and activate the cntlm proxy. Finally, set the proxy settings for HTTP and HTTPS.

Prerequisites

Before we begin, ensure that you have the following:

  • A Windows 10 system with Ubuntu WSL installed.
  • An HTTP proxy server that requires authentication. You should have the server address, port, domain, and your username.

Step 1: Install cntlm Proxy

The first step is to install the cntlm proxy. You can download the cntlm_0.92.3-1ubuntu2_amd64.deb package from this link. Once downloaded, copy the package into your WSL instance.

Open a terminal in your WSL instance and run the following command to install the package:

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

This command uses the dpkg package manager to install the cntlm package.

Step 2: Configure cntlm Proxy

After installing cntlm, you need to configure it. Open the /etc/cntlm.conf file in a text editor with the following command:

$ sudo nano /etc/cntlm.conf

This command uses sudo for administrative privileges and nano as the text editor. You can replace nano with your preferred text editor.

Update the configuration file with the required settings. Here’s an example configuration:

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

Replace Domain with your domain, username with your username, and 1.2.3.4:5678 with your proxy server address and port. The Listen directive specifies the port on which cntlm will listen for requests.

Save the changes and exit the text editor.

Step 3: Test and Verify cntlm

Now, you need to test cntlm with a website. Run the following command:

$ cntlm -M http://www.google.com

This command tests cntlm by trying to access http://www.google.com. If prompted, enter your password for authentication.

If the authentication is successful, generate hashes for the authentication by using the -H switch:

$ cntlm -H

This command generates the PassLM, PassNT, and PassNTLMv2 hashes. Note down these hashes.

Step 4: Add Hashes to cntlm Configuration

Open the /etc/cntlm.conf file again:

$ sudo nano /etc/cntlm.conf

Update the configuration file with the generated hashes:

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

PassLM 123456789ABCDEF123456789ABCDEF12
PassNT 123456789ABCDEF123456789ABCDEF12
PassNTLMv2 123456789ABCDEF123456789ABCDEF12 # Only for user 'username', domain 'Domain'

These hashes represent your password in a form that cntlm can use for authentication. Save the changes and exit the text editor.

Step 5: Activate the cntlm Proxy

Restart the cntlm service to activate the proxy:

$ sudo systemctl restart cntlm

This command restarts the cntlm service, applying the changes you made to the configuration file.

Step 6: Configure Proxy Settings

Finally, you need to set the proxy for HTTP and HTTPS. Run the following commands:

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

These commands set the proxy to localhost at port 3128, which is where cntlm is listening for requests.

Conclusion

Congratulations! You have successfully configured an HTTP proxy with authentication on Ubuntu WSL on Windows 10 using cntlm proxy. You can use these proxy settings for applications that support proxy configuration. Make sure to replace the placeholders with your actual information.

Remember, if you open a new terminal session, you will need to re-export the http_proxy and https_proxy variables. To make these settings persistent, you can add the export commands to your .bashrc or .bash_profile file.

Happy coding!

What is Ubuntu WSL?

Ubuntu WSL (Windows Subsystem for Linux) is a compatibility layer that allows you to run a Linux environment directly on your Windows 10 system. It provides a full-fledged Ubuntu terminal experience and allows you to run Linux commands and applications without the need for a virtual machine or dual-boot setup.

Why would I need to configure an HTTP proxy with authentication on Ubuntu WSL?

You might need to configure an HTTP proxy with authentication on Ubuntu WSL if you are working behind a corporate firewall or need to access the internet through a proxy server that requires authentication. This is common in enterprise environments where internet access is restricted and proxy servers are used for security and monitoring purposes.

Can I use a different proxy server instead of `cntlm`?

Yes, you can use a different proxy server instead of cntlm, but the steps mentioned in this guide specifically cover the installation and configuration of cntlm proxy. If you choose to use a different proxy server, the process may vary, and you will need to refer to the documentation or guides specific to that proxy server.

How do I find the proxy server address, port, domain, and username?

To find the proxy server address, port, domain, and username, you should reach out to your network administrator or IT department. They will be able to provide you with the necessary information to configure the proxy settings. These details are specific to your network setup and can vary from organization to organization.

How can I make the proxy settings persistent?

To make the proxy settings persistent, you can add the export commands for http_proxy and https_proxy to your .bashrc or .bash_profile file. This ensures that the proxy settings are automatically applied every time you open a new terminal session. Simply open the respective file in a text editor and add the export commands at the end. Save the file and the changes will take effect upon next login or terminal session.

Leave a Comment

Your email address will not be published. Required fields are marked *