![如何在 cURL 中传递我的 Windows 凭据?](https://linux22.com/image/1707854/%E5%A6%82%E4%BD%95%E5%9C%A8%20cURL%20%E4%B8%AD%E4%BC%A0%E9%80%92%E6%88%91%E7%9A%84%20Windows%20%E5%87%AD%E6%8D%AE%EF%BC%9F.png)
我正在编写一个使用 cURL 从内部 Web 服务器提取数据的脚本。我可以明确使用 --user 和 --ntlm,一切运行正常,但我无法让它识别登录的用户并透明地传递它。如果我在 Chrome/Firefox/IE 中访问同一个网站,它会立即授予我权限而无需任何提示(如果这很重要,我们在这里使用代理)。服务器正在使用 IIS。
答案1
我使用(在Windows域环境中):
curl --ntlm -u : ...
cUrl 知道提供我的域凭据,并且每次都有效。
答案2
使用-u :
提供空的用户代码和密码,让 cURL 从凭证存储中获取这些信息。
我在 Unix 上通过 GSSAPI 使用它,curl -u : --negotiate ...
答案3
为了详细说明@Phil P 的回答,下面是我在 ubuntu 盒子里的操作方法。
- 查找域控制器的 IP 地址,获取有关如何执行此操作的说明这里
- 安装 kerberos
sudo apt-get install krb5-user
在您的
/etc/krb5.conf
[libdefaults] default_realm = YOURDOMAN # note that this must be in UPPER CASE krb4_config = /etc/krb.conf krb4_realms = /etc/krb.realms kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true v4_instance_resolve = false v4_name_convert = { host = { rcmd = host ftp = ftp } plain = { something = something-else } } fcc-mit-ticketflags = true [realms] YOURDOMAN = { kdc = YOUR_DOAMIN_CONTROLLER_IP } [domain_realm] yourdomain = yourdomain yourdomain. = yourdomain