<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>TomsBlog</title>
    <link>http://www.toms-blog.com/tags/proxy/index.xml</link>
    <description>Recent content on TomsBlog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-uk</language>
    <atom:link href="http://www.toms-blog.com/tags/proxy/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Linux behind NTLM authentication proxy using CNTLM</title>
      <link>http://www.toms-blog.com/post/linux-behind-ntlm-authentication-proxy-using-cntlm/</link>
      <pubDate>Sat, 13 Oct 2012 18:16:57 +0000</pubDate>
      
      <guid>http://www.toms-blog.com/post/linux-behind-ntlm-authentication-proxy-using-cntlm/</guid>
      <description>&lt;p&gt;Sometimes you will find your server sat behind a proxy designed for human traffic rather than server traffic and so requires authentication.&lt;/p&gt;

&lt;p&gt;Although the NTLM protocol is grossly insecure it still seems to used in a lot of proxies. To get your server to download updates you will need to make your server play nice with this authentication as a lot of software does not support the NTLM protocol.&lt;/p&gt;

&lt;p&gt;CNTLM solves this issue by adding another proxy layer in front of your software which does not require authentication.&lt;/p&gt;

&lt;p&gt;You can download it from here &lt;a href=&#34;http://cntlm.sourceforge.net/&#34;&gt;http://cntlm.sourceforge.net/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are installing this on CentOS so we need the RPM, for Ubuntu get the DEB file alternatively download the source code and compile it.&lt;/p&gt;

&lt;p&gt;So on CentOS run:&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #f0f3f3&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span&gt;&lt;/span&gt;rpm -i cntlm-0.92.3-1.x86_64.rpm
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;On Ubuntu run:&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #f0f3f3&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span&gt;&lt;/span&gt;dpkg -i cntlm_0.92.3_amd64.deb
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Once installed edit the configuration file  /etc/cntlm.conf&lt;/p&gt;

&lt;p&gt;Set the username to your domain username and set the domain:&lt;/p&gt;

&lt;div class=&#34;box&#34;&gt;
&lt;p&gt;Username        proxyaccess&lt;/p&gt;

&lt;p&gt;Domain          contorso.com&lt;/p&gt;

&lt;/div&gt;

&lt;p&gt;Remove any passwords. Set the port you want it to listen on, the default is 3128 and set the proxy server you want to go through:&lt;/p&gt;

&lt;div class=&#34;box&#34;&gt;
&lt;p&gt;Listen 3128&lt;/p&gt;

&lt;p&gt;Proxy           10.0.0.1:8080&lt;/p&gt;

&lt;/div&gt;

&lt;p&gt;All we need to do now is create the password hash:&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #f0f3f3&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span&gt;&lt;/span&gt;cntlm -H -M http://10.0.0.1:8080 -c /etc/cntlm.conf
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;-H means create a hash, -M specifies the proxy server and -c specifies the config file to use.&lt;/p&gt;

&lt;p&gt;You will be asked for your password type it and then a hash will be created like below:&lt;/p&gt;

&lt;div class=&#34;box&#34;&gt;
&lt;p&gt;—————————-[ Profile  1 ]——&lt;/p&gt;

&lt;p&gt;Auth            NTLM&lt;/p&gt;

&lt;p&gt;PassNT          44345CE5DA10BCDF46CB34BAB4B5EEF6&lt;/p&gt;

&lt;p&gt;PassLM          BA46510ADEFAE56345ACC34156ADEE36&lt;/p&gt;

&lt;p&gt;————————————————&lt;/p&gt;

&lt;/div&gt;

&lt;p&gt;Copy all of this output and past it into your configuration file. Now all you need to do is start cntlm:&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #f0f3f3&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span&gt;&lt;/span&gt;cntlm -c /etc/cntlm.conf
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If you get “Exiting with Error check the Logs”. Have a look in the logs&lt;/p&gt;

&lt;p&gt;If you see this entry:&lt;/p&gt;

&lt;p&gt;cntlm: Cannot bind port 3128: Address already in use!&lt;/p&gt;

&lt;p&gt;CNTLM is already running have a look by running:&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #f0f3f3&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span&gt;&lt;/span&gt;ps aux | grep cntlm
&lt;span style=&#34;color: #336666&#34;&gt;kill&lt;/span&gt; -9 PROCESSID
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Where PROCESSID is the ID of the process you want to kill.&lt;/p&gt;

&lt;p&gt;Now try and run CNTLM again and you should be done.&lt;/p&gt;

&lt;p&gt;All you have to do now is point your programs to &lt;a href=&#34;http://127.0.0.1:3128&#34;&gt;http://127.0.0.1:3128&lt;/a&gt; for example for yum edit /etc/yum.conf and add:&lt;/p&gt;

&lt;div class=&#34;box&#34;&gt;
&lt;p&gt;proxy = &lt;a href=&#34;http://127.0.0.1:3128&#34;&gt;http://127.0.0.1:3128&lt;/a&gt;&lt;/p&gt;

&lt;/div&gt;

&lt;p&gt;Now YUM should work. Dont forget to have a look in /var/log/messages or /var/log/syslog for any errors.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>