Skip to content

Instantly share code, notes, and snippets.

@triskell
Last active April 13, 2021 10:42
Show Gist options
  • Save triskell/2b0922a2469a448b507b to your computer and use it in GitHub Desktop.
Save triskell/2b0922a2469a448b507b to your computer and use it in GitHub Desktop.
[Windows 7] CNTLM and NPM behind NTLM proxy

CNTLM and NPM behind NTLM proxy on Windows 7

CNTLM

  • Install CNTLM in a folder where you have full rights to run it as administrator.

  • Open cntlm.ini and fill it :

Username    YOUR_USERNAME
Domain      YOUR_DOMAIN
Proxy       YOUR_PROXY_IP:PORT
Listen      53128

!!! DON'T FILL THE PASSWORD FIELD !!!

  • Open a console to generate password hashes :
> cd c:\the_install_directory_of_cntlm
> cntlm –c cntlm.ini –H
Password: ...type proxy password here...
PassLM          D6888AC8AE0EEE294D954420463215AE
PassNT          0E1FAED265D32EBBFB15F410D27994B2
PassNTLMv2      91E810C86B3FD1BD14342F945ED42CD6

Copy those tree lines behin Domainfield. !!! AGAIN, DON'T FILL THE PASSWORD FIELD !!!

  • Run the console as administrator and copy the following line to determine if the settings work :
    cntlm –c cntlm.ini –I –M http://www.google.co.uk You should have a success message. If not, check the previous steps.

  • (Optional, only if the "Start CNTML proxy" shortcut does not exist yet) Create start_cntlm.bat file where you want :

cd c:\the_install_directory_of_cntlm
cntlm -v -f -c "cntlm.ini"
  • Run start_cntlm.bat as administrator to start CNTLM service. Keep the console open. Closing it will stop the service.

NPM

  • Open a console and copy those 3 lines :
> npm config set proxy http://localhost:53128
> npm config set https-proxy http://localhost:53128
> npm config set registry http://registry.npmjs.org
  • Start CNTLM service.

  • Every nmp command should work. You can try with :
    > npm view qunit

  • Enjoy.

Sources

[http://stackoverflow.com/questions/18569054/npm-behind-ntlm-proxy/18570201#18570201] [http://stormpoopersmith.com/2012/03/20/using-applications-behind-a-corporate-proxy/]

@genotrance
Copy link

Just use Px: http://github.com/genotrance/px

No need to provide any credentials - Px just authenticates as the logged in user. Super easy to setup and use and no worries of locking out your account cause you forgot to update the CNTLM.ini password hashes.

@alflanagan
Copy link

Thanks, worked like a charm!

@rozaydin
Copy link

Works great :) Thanks a lot

@johnyesberg
Copy link

johnyesberg commented Apr 10, 2019

I was getting "I'm a teapot" errors until I changed the registry to use https instead of http as discussed at stackoverflow

npm config set registry https://registry.npmjs.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment