This forum has been archived. All content is frozen. Please use KDE Discuss instead.

★ How to set system wide proxy with authentication in KDE ★

-2

Votes
1
3
Tags: None
(comma "," separated)
erkexzcx
Registered Member
Posts
6
Karma
0
OS
omg sorry guys, this forum log in is so complicated, I found out that my username is "erikasb" instead of "erkexzcx".... :'( ok, time to modify it... keep reading ;)
Introduction what is it, what is it for, and how it works.

You will need to download an application - cntlm (All info how below)

After reading Google how to enable authentication, I haven't got any luck by adding info to apt.conf file, by creating new scripts etc... This is just the only one way how it worked for me, and now I have great working computer on school network through proxy!

This is tutorial how to set authentication for proxy system wide.
This is usually for schools, when students are supposed to use their proxy with authentication. NTLM is by Microsoft, so Linux doesn't work very well with it.
The best thing that this app will not change any dangerous system files. :)
Turns on Automatically on start-up. (It should does, on some Linux OS it doesn't).

How to download

The magic name of that application is CNTLM.
It's original webpage is http://cntlm.sourceforge.net/
Download links are here http://sourceforge.net/projects/cntlm/f ... %200.92.3/

If you have no idea, click on one of those links:
64Bit DEB installation file: http://sourceforge.net/projects/cntlm/files/cntlm/cntlm%200.92.3/cntlm_0.92.3_amd64.deb/download
32Bit DEB installation file: http://sourceforge.net/projects/cntlm/files/cntlm/cntlm%200.92.3/cntlm_0.92.3_i386.deb/download

Or, if you are not Debian/Ubuntu based OS user (like wifislax), you can download source and compile it. The best thing that source doesn't need any external libraries, just gcc (or g++)compiler, that usually all Linux distributions has (except Lubuntu :D ).
Download source and compile yourself: http://sourceforge.net/projects/cntlm/files/cntlm/cntlm%200.92.3/cntlm-0.92.3.tar.gz/download


How to install/compile

I hope you all guys know how to use terminal main commands, like cd or ls
For deb files:
Simple:
Code: Select all
dpkg -i FILENAME.deb

How to compile source code (do copy-paste, start at the same directory where file is):
Code: Select all
sudo su #We will gain root access for further installation...
tar -xvzf cntlm-0.92.3.tar.gz
cd cntlm-0.92.3
./configure
make
make install


How to configure

I always use this method below and always works.
READ carefully, because it has unpatched bug.

Open terminal and paste this code (as text editor am using default kate)
Code: Select all
sudo kate /etc/cntlm.conf


Then, some text will popup.
Delete EVERYTHING and copy-paste text from below. (I also added picture even below to see what I am talking about)
Code: Select all
Username YOUR_USERNAME
Domain YOUR_DOMAIN
Proxy YOUR_PROXY

#Leave settings below as default, unless '3310' want to change to any other port...
NoProxy localhost, 127.0.0., 10., 192.168.*
Listen 3310


Attention! Ensure that you've left an empty line at the end of file. I found in Google that this is bug. Without that empty line it doesn't work!

Image

And save file. I suggest to leave terminal opened for a while.
Sorry after edit I was too lazy to change picture to remove a password line... Whatever, ignore, continue... ;)

Now go back to terminal. Type this:
Code: Select all
cntlm -H

and then type your proxy password. Click enter and then cntlm will print out 3 text lines. Copy all three lines from terminal and and paste to /etc/cntlm.conf file under Domain, so it will look like this

Code: Select all
Username YOUR_USERNAME
Domain YOUR_DOMAIN
PassLM          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PassNT          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PassNTLMv2      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX    # Only for user 'your_user', domain 'your_domain'
Proxy YOUR_PROXY

#Leave settings below as default, unless '3310' want to change to any other port...
NoProxy localhost, 127.0.0., 10., 192.168.*
Listen 3310



Explanation of
Code: Select all
cntlm -H
- if you sniff network using "Ettercap-gui" you may find your password, so we use hashes instead, not a plain password ;)

Enabling proxy under KDE

Ok, we have all the settings we need for cntlm application.

There you go two commands.
Code: Select all

#Activate CNTLM application to run in background and use settings from our /etc/cntlm.conf file
cntlm

#Activate CNTLM application to run in terminal as process - just to check output:
cntlm -v -c /etc/cntlm.conf

#Kill CNTLM background process.
kill -9 $(pidof cntlm)


At first time, I suggest kill cntlm, and then run from terminal. See how terminal prints result. If it doesn't say much about errors and keeps running (after cntlm activation command you should not be able to write anymore commands, you may open new tab or terminal instead).
So if it happened - I suggest reboot your computer and after logging in to your computer, check task manager for cntlm (As default, task manager is CTRL+ESC).
If you see it running, everything is 99,9% OK! :)


Step 1 - proxy in KDE
Go to System settings --> Network settings --> Proxy (You are here as default) --> Use manually specified proxy settings
Enter this proxy to first line and click on Use this proxy for all protocols.
Code: Select all
127.0.0.1:3310


Example:
Image

Remember when we set listening port to 3310? You can set anything you want, that is not used. :) So if you left 3310 port, your local proxy is now 127.0.0.1:3310

Step 2 - proxy in Terminal

I understand that sometimes is not enough simply change proxy in settings. Terminal ignores them :P
However, terminal apps like ping or add-repository (I don't remember correct name) still doesn't work through proxy. I have no idea, probably doesn't support, but things like apt-get works fine!

Enter this command in terminal:
Code: Select all
sudo kate /etc/apt/apt.conf


An empty file will popup. It might not even exists!
Now copy/paste those commands into that file and save it (save and create it).
Code: Select all
Acquire::http::proxy "http://127.0.0.1:3310/";
Acquire::ftp::proxy "ftp://127.0.0.1:3310/";
Acquire::https::proxy "https://127.0.0.1:3310/";


Example:
Image

Tips and tricks - for other Linux distributions - workarounds

Something not working?

1. Check if you've left an empty line in file /etc/cntlm.conf
2. Try to run CNTLM from terminal (kill it before doing that if it's running), check terminal input.
3. Check /etc/cntlm.conf if you have entered all settings correctly (use my picture example) + if you haven't accidentally deleted field.
4. Reboot your pc.
5. On some Linux OS some programs, like google-chrome-stable ignores proxy settings. Doesn't it happening to you? Set proxy for terminal. Turn off terminal, turn it on again and try sudo apt-get update. See if it works.


Doesn't start automatically after PC boot?

Two ways:
1. Go to your Desktop Environment settings and add startup command: cntlm -v -c /etc/cntlm.conf
Or if you can't find it, just manipulate applications. Add any application to startup, then just change it's command. ;)
2. Go to google and search for file which contains commands at startup. Search something like that: http://bit.ly/LN1avN
Then simply follow instructions and add command somewhere where you should do: cntlm -v -c /etc/cntlm.conf

Simply step how to reverse proxy for terminal

You set proxy for terminal that 3 commands in /etc/apt/apt.conf.
Now you want to disable proxy for terminal. But later you will want to enable it back.

Simply add # symbol before everyline:
Code: Select all
#Acquire::http::proxy "http://127.0.0.1:3310/";
#Acquire::ftp::proxy "ftp://127.0.0.1:3310/";
#Acquire::https::proxy "https://127.0.0.1:3310/";


and Linux OS ignores those lines, and result is the same as empty file ;)
erkexzcx
Registered Member
Posts
6
Karma
0
OS
However, we can add a line to
Code: Select all
/etc/cntlm.conf
with this text
Code: Select all
Gateway yes

and cntlm will be available for other devices which have proxy settings but doesn't have authentication options.!

Another way to get your laptop running cntlm to act as proxy is run
Code: Select all
cntlm -g


but what proxy settings to use on other devices after I set up cntlm to work in gateway mode?
Attention it's actually confusing - it's not gateway, it works as a proxy!

simple way - must be on LAN!
Go to your laptop terminal, type
Code: Select all
ifconfig
, find your active interface, and find your ip4 adress.

so proxy for other devices on the same network would be
Code: Select all
your_ip4_adress:3310
(or your custom port if you are not using 3310 port)


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]