So your college wifi also has a proxy server, and you want to configure your system to use it. Here’s how you do it.

NOTE: In this post I will only focus on Linux based distros like Ubuntu, Fedora, Arch, etc.

Understanding what a proxy server is

You might have given someone’s “proxy” in college attendance, right 😉? Basically you pretend to be someone when you are not. In the same way, a proxy server is a server that acts as an intermediary (gateway) between your computer and the internet. It can be used to hide your identity, or to access the internet.

Usually this is how we connect to the internet (I am using a very simplified diagram here):

Internet Connection

  • We make a request, and the request is sent to the target.
  • The target sends a response, and the response is sent to us.

Now with the proxy server in the picture, it looks like this:

Internet Connection with Proxy

  • We make a request, and the request is sent to the proxy server.
  • The proxy server sends the request to the target.
  • The target sends a response, and the response is sent to the proxy server.
  • We get the response from the proxy server.

So, the proxy server is just an intermediary between us and the target.

What are the advantages of using a proxy server?

  • You can hide your identity.
  • Proxy server can also cache the data, so you can access it faster.
  • Act as a firewall.

There are different types of proxy servers but we will not focus on them here.

But if you don’t configure the proxy address properly you won’t be able to surf the internet, install packages or update your system.

Proxy Address and Port number

Before configuring you should know the address of the proxy server and the port number. You can get this information from your college network admin.

In my case it is 10.32.0.1 and the port is 8080.

NOTE: Sometimes if you are not very sure about the proxy address, take a look at the IP address of your system. Replace the 3rd octent with 0 and last octet with 1 and try to ping it. If it is the proxy server, it will respond.

My Ip

So my IP is 10.32.2.149.

Making the third octet 0 and the last octet 1 we get 10.32.0.1. Try to ping that.

Pinging

Configuring the proxy

In Linux to set proxy we have to update the environment variables HTTP_PROXY, HTTPS_PROXY and many more. But I will show you a trick set all your proxies very easily.

Step 1. Download the repo Proxyman

For this particular step, use your mobile data hotspot. Visit this link and download the repo:

Download Repo

NOTE: You can’t use git clone because we haven’t set the proxy yet.

Step 2. Unzip the downloaded zip file

Unzip the file by using the unzip command.

$ unzip ProxyMan-master.zip 
Archive:  ProxyMan-master.zip
c38b13e28d5ec285dcc8b07e7bd6e939bc1be195
   creating: ProxyMan-master/
  inflating: ProxyMan-master/LICENSE  
  inflating: ProxyMan-master/README.md  
  inflating: ProxyMan-master/_config.yml  
  inflating: ProxyMan-master/apt.sh  
  inflating: ProxyMan-master/bash-zsh.sh  
  inflating: ProxyMan-master/changelog.md  
  inflating: ProxyMan-master/common.txt  
  inflating: ProxyMan-master/configs.sh  
  inflating: ProxyMan-master/dnf.sh  
  inflating: ProxyMan-master/docker.sh  
  inflating: ProxyMan-master/dropbox.sh  
  inflating: ProxyMan-master/environment.sh  
  inflating: ProxyMan-master/git.sh  
  inflating: ProxyMan-master/gsettings.sh  
  inflating: ProxyMan-master/install  
  inflating: ProxyMan-master/kde5.sh  
  inflating: ProxyMan-master/main.sh  
  inflating: ProxyMan-master/node-yarn.sh  
  inflating: ProxyMan-master/npm.sh  
  inflating: ProxyMan-master/proxyman  
  inflating: ProxyMan-master/shellrc.sh  
  inflating: ProxyMan-master/variables.sh  

Step 3. Configuring proxy

cd into that directory and run the main.sh script.

cd Proxyman-master
./main.sh

It should say something like this:

ProxyMan lets you set system-wide proxy settings.
  https://github.com/himanshub16/ProxyMan 

Usage: proxyman [command]
  or   ./main.sh [command]

Commands:
 set         set proxy settings
 unset       unset proxy settings
 list        list current settings
 configs     lists available configs
 load        load a profile
 delete      delete a profile
 help        show this help

Allowed options: set, unset, list, configs, load, delete, help

Done

So, now to set the proxy run the command ./main.sh set

./main.sh set

Now, it will ask you for some inputs.

  • HTTP Proxy Host Enter the host address, in my case 10.32.0.1 (we found it in the earlier section).
  • HTTP Proxy Port Enter the port number, in my case 8080.
  • Use auth - userid/password (y/n)? Press enter.
  • Use same for HTTPS and FTP Press y and enter.
  • No Proxy (default localhost,127.0.0.1,192.168.1.1,::1,*.local) Press enter.
  • Save profile for later use (y/n)? You can choose n, but if you want to reuse this proxy settings again press y and enter. I will choose y and then pass a name to save my config.
  • Select targets to modify Press 1 and enter.

It will then ask for your root password and you are done.

Proxyman

You should now be able to surf your internet, git clone, install packages, etc.

Unset Proxy

Now, let’s say you want to unset your proxy settings. It’s very simple as well.

./main.sh unset

It will again ask you Select targets to modify, press 1 and enter.

If you have saved your profile while setting the proxy the first time you can directly use that settings by using the command

./main.sh load <config-name>

I saved it as MyHall so I will run:

$ ./main.sh load MyHall
Loading profile :  MyHall 
HTTP  > 10.32.0.1 8080
HTTPS > 10.32.0.1 8080
FTP   > 10.32.0.1 8080
no_proxy > localhost,127.0.0.1,192.168.1.1,::1,*.local
Use auth >   
Use same > y
Config >  
Targets > 
 Select targets to modify 
| 1 | All of them ... Don't bother me
| 2 | Terminal / bash / zsh (current user) 
| 3 | /etc/environment
| 4 | apt/dnf (Package manager)
| 5 | Desktop settings (GNOME/Ubuntu/KDE)
| 6 | npm & yarn
| 7 | Dropbox
| 8 | Git
| 9 | Docker

Separate multiple choices with space
 ? 1
Setting proxy...
To activate in current terminal window
run source ~/.bashrc
reloading docker
done
Done

And that should set my proxy.

Using git under SSH

If you are using a proxy network then you won’t be able to use SSH with git. Basically you will be to run commands like this:

git clone https://github.com/arnabsen1729/arnabsen1729.git # THIS WILL WORK

But, this won’t

git clone git@github.com:arnabsen1729/arnabsen1729.git # THIS WON'T

I prefer to use git ssh cause I don’t want to manually enter password everytime. To overcome this we need to install corkscrew .

Corkscrew is a tool for tunneling SSH through HTTP proxies.

To install it first clone the repo:

git clone https://github.com/bryanpkc/corkscrew.git

Then follow the installation guide here .

To verify the installation type corkscrew in the terminal.

$ corkscrew
corkscrew 2.0 (agroman@agroman.net)

usage: corkscrew <proxyhost> <proxyport> <desthost> <destport> [authfile]

Now, we will add a config for SSH. So, cd into the .ssh dir.

cd ~/.ssh

NOTE: If you don’t have one, create it by mkdir ~/.ssh and then run the above command.

There should be a config file. If there is none, then create one.

Inside the config add:

Host github.com
  Preferredauthentications publickey
  AddressFamily inet
  Hostname ssh.github.com
  Port 443
  User git
  ProxyCommand /usr/bin/corkscrew 10.32.0.1 8080 %h %p

Replace the 10.32.0.1 with your own proxy address and 8080 with your own port.

Save this file and you should be good to go.


Thanks for reading this article, if you faced any issue or had a difficulty in understanding please feel free to reach out to me in any of the social links or email .