How to use cntlm for authenticating against a proxy server using Windows NT credentials ?

In this blog, I will show the commands and configuration files I used to configure cntlm for authenticating against a proxy server.

Let’s say your Linux machine IP is 192.168.10.20, your proxy server is proxy.us.linux.com:80 and your NT credentials are linus_torvalds (username), icreatedlinux(password), americas (domain).

 

1. Download and install the cntlm package from https://sourceforge.net/projects/cntlm/files/cntlm/

2. Get the password hash using domain and username.
   Enter the password (icreatedlinux) when prompted                                                              
   cntlm -H -d americas -u linus_torvalds                                                                               

3. The output of the above command will be similar to the below text
     PassLM A412DC1CB2E146FB252B4ACA4AEBFB12                                              
     PassNT 56A6BC6FB7E1AD70D3DAA81D82CA43A7
     PassNTLMv2 B901126105CEC54F9DF02AC10CA5AE4A # Only for user 'linus_torvalds', domain 'americas'                        

 4. Configure cntlm. Edit /etc/cntlm.conf
     Username linus_torvalds                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
     Domain america
     PassLM A412DC1CB2E146FB252B4ACA4AEBFB12
     PassNT 56A6BC6FB7E1AD70D3DAA81D82CA43A7                                                               
     PassNTLMv2 B901126105CEC54F9DF02AC10CA5AE4A 
     Proxy proxy.us.linux.com:80
     NoProxy localhost, 127.0.0.*
     Listen 3128  
     Listen 127.0.0.1:3128
     Listen 192.168.10.20:3128  
     Auth NTLMv2                                                                                                                                 

5. Set proxy environment variables
     export http_proxy=192.168.10.20:3128                                                                                                          
     export https_proxy=${http_proxy}
     export ftp_proxy=${http_proxy}      

6. Start cntlm service

Links

  1. https://gist.github.com/lpf23/d3c4e1ef158c7fb4a909

Leave a comment