Wednesday, December 07, 2011

Setting up proxy in Kubuntu

I have been forced to be away from Linux in my work place due to network proxy (with user authentication) in my Institution. The setup was difficult and even though done, it didn't work well with all the functionality, like apt-get, console ssh-es and wget-s etc. I had to use Windows for a while, but my heart felt something missing. That's due to my long time relationship with GNU/Linux. I love KDE and I feel not at home with Gnome. Though setting up proxy in GUI under Ubuntu provides it system wide upto to the console (konsole, terminal), it was not the case in Kubuntu. In Kubuntu, I could setup the proxy from the KDE control centre, but it provides the proxy info to GUI apps like Firefox where I am required to enter my username and pw with a pop-up. But there is a serious bug in KDE, that other KDE apps report a proxy authentication failure error even if I provided the right information. For e.g., Rekonq or Konqueror, would ask for proxy authentication the first time when I open a first page, it would open up that page. But, in the next time, if I provide the same proxy authentication, it would mention there is an authentication failure. I have had this problem several times in all KDE distros I have tried and its KDE bug that needs to fixed.

In frustration I tried several distros: Simply Mepis, Ubuntu and OpenSuSE 12.1. etc. I hate Gnome and now you can imagine the situation with Unity. Simply Mepis worked fine in resolving my proxy issues using the given Mepis control centre, but for some reason it stopped working after a while and it also did not allow reverting back to Kdenetwork manager. Opensuse, though I have I a high regard for that distro, did not work. Even in a proxyless environment in my home, its clunky YAST2 could not fetch the update repos. I couldn't figure out why? I have to say Opensuse's software repo refreshing (everytime which is default) is slow and patience testing. Debian beats OpenSuse infinite times in this issue. Its easier to setup the repos and the package info fetching is fast. Finally I returned to my good old friend Kubuntu. But I didn't know how to setup proxy for the console.

export http_proxy="http://proxy.xxx.xx:80xx/"

did not work:

Finally (Hurray) with the help of our uni's sysadmin, I figured out where the proxy environment is set in Ubuntu- /etc/environment (we grep -ed /etc * for "http_proxy" and found out where it is located.)

So to setup proxy in Kubuntu in CLI, as a superuser (sudo), edit /etc/environment file

append the following lines at the end*:

http_proxy="http://proxy.xxx.xx:80XX/"
https_proxy="https://proxy.xxx.xx:80XX/"
ftp_proxy="ftp://proxy.xxx.xx:80XX/"

*replace "proxy.xxx.xx" with your work/uni's proxy server name,replace "80XX" with your work/uni's proxy port number.

Save it and reboot your system. You can get internet in your konsole and you can ssh, ping or wget to any computer in the web.

Now I am back at work with my favourite KDE :)

Additional how-t0 :

To setup apt-get to your proxy environment, create a apt.conf file in your /etc/apt/ folder and specify the proxy like this. As a su or sudoer edit apt.conf file (create one if there isn't)

Acquire::http::Proxy "http://username:password@proxy.xxx.xx:80XX";