[PYTHON] Run conda / pip / gem under NTLM authentication proxy environment

Overview

--If you can't try the Proxy setting information method on the net of conda / pip / gem, it may be because of NTLM authentication. --You can use conda / pip / gem by putting cntlm locally and passing it through.

environment

procedure

First, read [I want to use npm with Cntlm even under NTLM proxy environment_OPC Diary] 2 and set cntlm. You can skip the "npm settings" part.

What is Cntlm?

Cntlm is a Proxy server that acts as a proxy for NTLM authentication instead of various tools under the NTLM authentication Proxy environment provided as open source. This time it runs on Windows, but there are also Linux and Mac versions. (In fact, it is essential if you use Homebrew on Linux or Mac under the NTLM authentication Proxy environment.)

Summary

So, if you use Cntlm as a tool that can set proxy, not limited to npm, I think you can have an advantageous battle!

conda [Prepare Python (Anaconda) environment on Windows under Proxy --Qiita] Read 3 and set the proxy setting of .condarc as follows.

proxy_servers:
    http: http://[Proxy address]:[port number]
    https: https://[Proxy address]:[port number]

If you use the default of cntlm.ini, the port number is 3128, so it is as follows.

proxy_servers:
    http: http://localhost:3128
    https: https://localhost:3128

pip [python memo pip under proxy, easy_install --Qiita] 4, execute the following before executing the command pip install.

set HTTP_PROXY=http://localhost:3128
set HTTPS_PROXY=https://localhost:3128

[Launch a command prompt with process-specific environment variables (PATH) set-Qiita] Using application example 1 of 6,

vbs excerpt


set env = shell.Environment("Process")
env.Item("HTTP_PROXY") =  "http://localhost:3128"
env.Item("HTTPS_PROXY") =  "https://localhost:3128"

It may be good to set as follows and launch the command prompt.

gem gem install can specify a proxy with -p, so do as follows.

> gem install serialport -r -p https://localhost:3128

[If certificate verify failed during gem install --- Qiita] You may need to replace the certificate with 5.

> gem install serialport -r -p http://localhost:3128
RROR:  Could not find a valid gem 'serialport' (>= 0), here is why:
         Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

If "certificate verify failed" occurs,

C:\Ruby23-x64\lib\ruby\2.3.0\rubygems\ssl_certs\AddTrustExternalCARoot-2048.pem

After backing up, open it in a text editor and

Certificates that can be seen in View in Base 64

I think you should copy and save the contents of.

There seems to be a method of do something with http, but it seems that "a message will appear if https is recommended for security", so this person Is it a little clean?

reference

[I want to use npm with Cntlm even under NTLM proxy environment_OPC Diary] 2 [[Windows] Forefront TMG's NTLM authentication proxy manages with Cntlm_engine shop] [1] [If certificate verify failed occurs during gem install --Qiita] 5 [Launch a command prompt with process-specific environment variables (PATH) set-Qiita] 6

[1]: http://sevenb.jp/wordpress/ura/2016/01/27/windowsforefront-tmg ntlm authentication proxy managed with cntlm /

Recommended Posts

Run conda / pip / gem under NTLM authentication proxy environment
Pip install (Windows) under Proxy environment
When pip fails under proxy environment
Use the pip command under an HTTP proxy environment that requires authentication
How to use pip3 under proxy environment Note
Docker under proxy environment
Pip install in proxy environment
python memo pip under proxy, easy_install
Quick reference table under Proxy environment
Execution of pip command under proxy (memorial)