node.js NTLM 代理背后的 NPM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18569054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NPM behind NTLM proxy
提问by kol
Is it possible to run npm installbehind an HTTP proxy, which uses NTLMauthentication? If yes, how can I set the server's address and port, the username, and the password?
是否可以在npm install使用NTLM身份验证的 HTTP 代理之后运行?如果是,如何设置服务器的地址和端口、用户名和密码?
回答by kol
I solved it this way (OS: Windows XP SP3):
我是这样解决的(操作系统:Windows XP SP3):
1.Download CNTLMinstaller and run it.
1.下载CNTLM安装程序并运行它。
2.Find and fill in these fields in cntlm.ini. Do not fill in the Passwordfield, it's never a good idea to store unencrypted passwords in text files.
2.在cntlm.ini 中找到并填写这些字段。不要填写该Password字段,将未加密的密码存储在文本文件中绝不是一个好主意。
Username YOUR_USERNAME
Domain YOUR_DOMAIN
Proxy YOUR_PROXY_IP:PORT
Listen 53128
3.Open console, and type these commands to generate password hashes.
3.打开控制台,输入这些命令来生成密码哈希。
> cd c:\the_install_directory_of_cntlm
> cntlm -H
Password: ...type proxy password here...
PassLM D6888AC8AE0EEE294D954420463215AE
PassNT 0E1FAED265D32EBBFB15F410D27994B2
PassNTLMv2 91E810C86B3FD1BD14342F945ED42CD6
4.Copy the above three lines into cntlm.ini, under the Domainfield's line. Once more, do not fill in the Passwordfield.Save cntlm.ini.
4.将以上三行复制到 cntlm.ini 中,在Domain字段行下。再一次,不要填写该Password字段。保存 cntlm.ini。
5.Open the Service Manager (from command line: services.msc), and start the service called "CNTLM Authentication Proxy".
5.打开服务管理器(从命令行:services.msc),并启动名为“CNTLM Authentication Proxy”的服务。
6.In the console, type these lines:
6.在控制台中,输入以下几行:
> npm config set proxy http://localhost:53128
> npm config set https-proxy http://localhost:53128
> npm config set registry https://registry.npmjs.org
7.Now npm view, npm installetc. should work. Example:
7.现在npm view,npm install等应该工作。例子:
> npm view qunit
...nice answer, no errors :)
回答by Toilal
CNTLM answer was working for me, but with connection errors make npm unusable. I've fixed them by adding this header in CNTML.
CNTLM 答案对我有用,但连接错误使 npm 无法使用。我已经通过在 CNTML 中添加这个头文件来修复它们。
Header Connection: close
回答by genotrance
Another alternative is to usePx for Windowswhich talks NTLM on your behalf like Cntlm and NTLMAps without having to provide your credentials. It uses the logged in user's credentials via SSPI.
另一种选择是使用Px for Windows,它代表您像 Cntlm 和 NTLMAps 一样谈论 NTLM,而无需提供您的凭据。它通过 SSPI 使用登录用户的凭据。
回答by adhocgeek
Rather than running CNTLM, you could instead try running Fiddlerwhen you need to use npm. I've found this works in fairly locked down environments (e.g. investment banks). It's also a tool that is fairly easy to make a business case for (if you need to) since it's invaluable for checking/creating/altering HTTP traffic.
当您需要使用 npm 时,您可以尝试运行Fiddler,而不是运行 CNTLM 。我发现这适用于相当封闭的环境(例如投资银行)。它也是一个相当容易为(如果需要)制作商业案例的工具,因为它对于检查/创建/更改 HTTP 流量非常宝贵。
I've had to go this route before due to usage of smartpass authentication - i.e. we didn't actually have passwords. At those locations setting up CNTLM would have been impossible.
由于使用了智能通行证身份验证,我之前不得不走这条路 - 即我们实际上没有密码。在这些位置设置 CNTLM 是不可能的。
回答by Dunken
You can pass the settings as parameters:
您可以将设置作为参数传递:
npm --proxy=http://username:password@proxyserver:port --proxy-https=http://username:password@proxyserver:port --registry=http://registry.npmjs.org/ install whateveryouwanttoinstall
回答by Sundara Prabu
- Open your
.npmrcfile in C:\users\username\ folder using notepad - Add the below lines..
- Replace domain, username, pwd, servername with your correct values
- Try to install or get packages now
If trying from Vs2017, close and reopen VS IDE, then only it works
proxy=http://DOMAIN%5CUSERNAME:[email protected]:6050 https-proxy=http://DOMAIN%5CUSERNAME:[email protected]:6050 http-proxy=http://DOMAIN%5CUSERNAME:[email protected]:6050 strict-ssl=false
.npmrc使用记事本打开C:\users\username\ 文件夹中的文件- 添加以下几行..
- 用正确的值替换域、用户名、密码、服务器名
- 立即尝试安装或获取软件包
如果从 Vs2017 尝试,关闭并重新打开 VS IDE,则只有它有效
proxy=http://DOMAIN%5CUSERNAME:[email protected]:6050 https-proxy=http://DOMAIN%5CUSERNAME:[email protected]:6050 http-proxy=http://DOMAIN%5CUSERNAME:[email protected]:6050 strict-ssl=false
回答by Rakesh Sharma
CNTLM didn't work for me. I tried all possible combinations. NPM was giving Authentication error. Fiddler came for rescue and saved my time. It is easy to install and configure. Set Fiddler Rule to Automatically Authenticated.In .npmrc set these
CNTLM 对我不起作用。我尝试了所有可能的组合。NPM 给出身份验证错误。Fiddler 前来救援并节省了我的时间。它易于安装和配置。将 Fiddler Rule 设置为 Automatically Authenticated.In .npmrc 设置这些
registry=http://registry.npmjs.org
proxy=http://127.0.0.1:8888
https-proxy=http://127.0.0.1:8888
http-proxy=http://127.0.0.1:8888
strict-ssl=false
It worked for me :)
它对我有用:)
Another Fiddler Option:
另一个提琴手选项:
A second way to make Fiddler act as an HTTP proxy for NTLM and other protocols is to leave the auto authenticate options/rules defaults in place and go to this setting from the menu bar:
使 Fiddler 充当 NTLM 和其他协议的 HTTP 代理的第二种方法是保留自动身份验证选项/规则默认值并从菜单栏中转到此设置:
Tools > Telerik Fiddler Options > Connections tab
工具 > Telerik Fiddler 选项 > 连接选项卡
Click on the Allow remote computers to connectcheckbox. You will see a dialog explaining the consequences of enabling this option. Restart Fiddler and update the .npmrcfile as shown above. Whenever you need npm to access the registry site just run Fiddler. This setting won't affect the way Fiddler runs for other captures.
单击允许远程计算机连接复选框。您将看到一个对话框,说明启用此选项的后果。重新启动 Fiddler 并更新.npmrc文件,如上所示。每当您需要 npm 访问注册表站点时,只需运行 Fiddler。此设置不会影响 Fiddler 为其他捕获运行的方式。
回答by kausik sen
CNTLM worked for me as suggested by KOL. Thanks KOL for that. Just wanted to add that there are some oddities in individual proxies because of which the password may not be acceptable when using simple cntlm -H.
CNTLM 按照 KOL 的建议对我来说有效。感谢 KOL。只是想补充一点,个别代理中有一些奇怪的地方,因此在使用 simple 时密码可能不可接受cntlm -H。
Use cntlm -I -M http://test.comand copy the below config after erasing older configs and you should be through.
cntlm -I -M http://test.com删除旧配置后使用并复制以下配置,您应该通过。
The output is like
输出就像
---------------------------------------------------
Auth NTLM
PassNT 8EE9B595A89F7D8774C2146FB302CBCF
PassLM 78901DA9889727EDE28EF9F2769485B9
----------------------------------------------------

