cntlm 的配置使用

代理

举例而言,通常我们可以这样代理上网,账号密码是明文的,会有信息安全问题。
export http_proxy=http://username:passwd@proxyhk.xxx.com:8080

cntlm

cntlm 是一个HTTP二级代理软件。 它主要的作用,是在能代理上网的前提下,给这个代理再做一个代理,提供给更多的下级用户。 下级用户不需要、也不可能知道代理的账户密码,这样既保障了安全、又实现了方便。

Cntlm is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy intended to help you break free from the chains of Microsoft proprietary world. You can use a free OS and honor our noble idea, but you can’t hide. Once you’re behind those cold steel bars of a corporate proxy server requiring NTLM authentication, you’re done with. The same even applies to 3rd party Windows applications, which don’t support NTLM natively.

cntlm 采用 NTLMv2 协议用于鉴权用户身份。

Here comes Cntlm. It stands between your applications and the corporate proxy, adding NTLM authentication on-the-fly. You can specify several “parent” proxies and Cntlm will try one after another until one works. All auth’d connections are cached and reused to achieve high efficiency. Just point your apps proxy settings at Cntlm, fill in cntlm.conf (cntlm.ini) and you’re ready to do. This is useful on Windows, but essential for non-Microsoft OS’s.

在配置文件里需要提供上游代理,cntlm 会逐个尝试找到可用的代理,然后作为一个二级代理,分发给需要的下游用户。

There are many advanced features like NTLMv2 support, password protection, password hashing, completely mutliplatform code (running on just about every architecture and OS out there) and so much more. Cntlm eats up so little resources it can be used on embedded platforms as well - it’s written in plain C without any external dependencies.

安全、跨平台、高效、资源占用少

安装

sudo apt install cntlm 下载地址

配置

安装完后的默认配置文件为 /etc/cntlm.conf

最简配置如下

Username    USERNAME
Domain      COMPANY_DOMAIN
Password    ********

Proxy       proxy.company.com:8080
Proxy       proxy2.company.com:8080

NoProxy     localhost, 127.0.0.*, 10.*, 192.168.*, .company.com

Listen      3128

这个配置,仅能让本机访问。 如果要允许本机以外的机器访问,则需要再添加 Gateway yes
其中的 AllowDeny 顾名思义,就是白名单和黑名单了。
为了不显示用户密码,使用 AUTH 校验。

sudo cntlm -vc /etc/cntlm.conf -M http://baidu.com
section: global, Username = 'USERNAME'
section: global, Domain = 'COMPANY_DOMAIN'
section: global, Proxy = 'proxy.company.com:8080'
section: global, Proxy = 'proxy2.company.com:8080'
section: global, NoProxy = 'localhost, 127.0.0.*, 10.*, 192.168.*, .company.com'
section: global, Listen = '3128'
...
HEAD: HTTP/1.1 200 OK
OK (HTTP code: 200)
----------------------------[ Profile  1 ]------
Auth            NTLM
PassNT          7FA051B4B85F0E7EEBB24D3CD73E52B0
PassLM          23A1E1A7276E84EA4846D4C9FF957C35
------------------------------------------------
cntlm: Terminating with 0 active threads

把下面的内容放到配置文件中即可。

Auth            NTLM
PassNT          7FA051B4B85F0E7EEBB24D3CD73E52B9
PassLM          23A1E1A7276E84EA4846D4C9FF957C31

使用 cntlm -H 命令也可以生成秘钥的哈希

Password:
PassLM          7F4BB72132BAA2A01FA94BD623A70D3B
PassNT          2C27BB146F74625D159413FC1F30745F
PassNTLMv2      D3972609581D8260868ED588303F0FF0    # Only for user 'testuser', domain 'contoso'

使用

.bashrc 或其他个人配置文件中加上,注意这里的端口号就是配置文件设置的监听端口号。
之后 source 配置文件生效环境变量的修改。

export http_proxy="http://127.0.0.1:3128"
export https_proxy="http://127.0.0.1:3128"
export ftp_proxy="http://127.0.0.1:3128"

// or
export http_proxy=http://127.0.0.1:3128
export https_proxy=${http_proxy}
export ftp_proxy=${http_proxy}

重启服务

sudo systemctl reload cntlm

#关闭cntlm服务
sudo killall cntlm 

#开启cntlm服务
sudo cntlm
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
About Cntlm proxy Cntlm (user-friendly wiki / technical manual) is an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy intended to help you break free from the chains of Microsoft proprietary world. You can use a free OS and honor our noble idea, but you can't hide. Once you're behind those cold steel bars of a corporate proxy server requiring NTLM authentication, you're done with. The same even applies to 3rd party Windows applications, which don't support NTLM natively. Here comes Cntlm. It stands between your applications and the corporate proxy, adding NTLM authentication on-the-fly. You can specify several "parent" proxies and Cntlm will try one after another until one works. All auth'd connections are cached and reused to achieve high efficiency. Just point your apps proxy settings at Cntlm, fill in cntlm.conf (cntlm.ini) and you're ready to do. This is useful on Windows, but essential for non-Microsoft OS's. Cntlm integrates TCP/IP port forwarding (HTTP tunneling), SOCKS5 proxy mode, standalone proxy allowing you to browse intranet as well as Internet and to access corporate web servers with NTLM protection. There are many advanced features like NTLMv2 support, password protection, password hashing, completely mutliplatform code (running on just about every architecture and OS out there) and so much more. Cntlm eats up so little resources it can be used on embedded platforms as well - it's written in plain C without any external dependencies. Cntlm has been tested against various ISA servers, WinGate, NetCache, Squid and Tinyproxy with and without NTLM auth. Memory management audits and profiling are inherent part of the development process. Each change in the code is audited using Valgrind, which acts as a virtual CPU and checks behaviour of each instruction of the application being profiled. Using this marvelous tool, you can uncloak any imbalance in malloc/free calls (double free's or leaks), operations with uninitialized memory, access outside of properly allocated memory and oh so much more.
配置Docker网络代理,你可以参考Docker官方文档中的配置方法。首先,你需要确定要使用的代理服务器的地址和端口。如果你使用的是本地代理,比如localhost:3128,你需要在docker命令中添加--network host参数。这样Docker容器将能够正常使用本地代理。如果你使用的是外部IP地址的代理服务器,并且代理本身需要开启Gateway模式,你需要在Docker守护进程的配置文件中添加代理设置。具体的配置方法可以参考Linux下安装配置Cntlm代理的教程。完成配置后,你需要重启Docker守护进程使配置生效。你可以使用以下命令来重启Docker守护进程并查看配置是否正确: sudo systemctl daemon-reload sudo systemctl restart docker systemctl show --property=Environment docker /etc/systemd/system/docker.service.d 这样你就成功配置了Docker的网络代理。请根据你的实际情况进行相应的配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [快速设置 Docker 的三种网络代理配置](https://blog.csdn.net/peng2hui1314/article/details/124267333)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Docker 配置网络代理](https://blog.csdn.net/qq_39698985/article/details/123748820)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值