My notebook uses MacOS, and already set up http(s) proxy inside the Network Preferences , but always failed to install any packages when running npm install
in the terminal, it popped up the error 407 Proxy Authentication Required
.
So I installed the cntlm and applied the correct configuration.
Below is the test and it seems pass (return HTTP Code 200):
cntlm -c /usr/local/etc/cntlm.conf -I -M http://registry.npmjs.org/vue
Password:
Config profile 1/4... OK (HTTP code: 200)
----------------------------[ Profile 0 ]------
Auth NTLMv2
PassNTLMv2 28B089518C6573274C6B9D83D0XXXXXX
When I ran npm i vue-cli -g
, cntlm did receive the request as below:
cntlm -c /usr/local/etc/cntlm.conf -f
Oct 15 15:12:29 cntlm[17646] <Info>: Cntlm ready, staying in the foreground
Oct 15 15:12:38 cntlm[17646] <Info>: Using proxy company-proxy:80
Oct 15 15:12:38 cntlm[17646] <Debug>: 127.0.0.1 GET http://registry.npmjs.org/nexe
But nodejs threw out below exceptions:
npm i vue-cli -g
npm ERR! code E407
npm ERR! 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ): vue-cli@latest
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/****/.npm/_logs/2018-10-15T23_13_47_019Z-debug.log
It confused me: because the test is PASS, but why the cntlm still failed to connect to npmjs.org?
Finally find out the solution :
don't use plain text password ( add one #
at the beginning of the Password
line, like change Password XXX
to #Password XXX
)
use PassLM , PassNT , PassNTLMv2 instead (it seems hash values will prevent from auth handshake mechanism again, which should mean you are on behalf of the applications with logged in Windows user account).
The default cntlm configuration file already introduces the steps how to generate them.
My steps are as below:
execute cntlm -H -d your_domain -u your_username
then it prompts password, fill in your password then hit Enter :
The output will be like below:
Password:
PassLM F5314AF8A2DB16BDB7EE9FA6CFC5BC9A
PassNT 4EC02E0D65F8F0C1A9386C69CB6A2555
PassNTLMv2 28B089518C6573274C6B9D83D0EB8651
paste above hash values to the relevant fields in the configuration file.
save then restart cntlm , it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.