Curl回复了401:未授权,即使已发送用户名和密码

1zmg4dgp  于 2022-12-13  发布在  其他
关注(0)|答案(1)|浏览(848)

I have a batch script that uses curl to do a http-get request to a webserver in the network. Problem is in curl im getting a response of 401: Unauthorized even if i send the username and password compared to just entering the link in a browser like google chrome which returns 200: OK

C:\Users\myuser>curl -I "http://admin:admin1234@192.168.0.4/arg1=0&arg2=20&arg3=0"
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="Login to 28b6e642501d12764d8430059585d39b", qop="auth", nonce="1592879309", opaque="ecd7f630cfdef2dec4aebb35f81708e84d20a755"
Connection: close
Set-Cookie:secure; HttpOnly
CONTENT-LENGTH: 0

I have also tried:

curl -I -u admin:admin1234 "http://admin:admin1234@192.168.0.4/arg1=0&arg2=20&arg3=0"
curl -I -u admin:admin1234 "http://192.168.0.4/arg1=0&arg2=20&arg3=0"

With the same result 401: Unauthorized . I know it not a problem with the device im connecting to since if i use http://admin:admin1234@192.168.0.4/arg1=0&arg2=20&arg3=0 in google chrome, the device operates as it should and it also returns with 200: OK
Is there a different way of sending username and password, bonus if the username and password do not show up in any log files

mbjcgjjk

mbjcgjjk1#

线索在此响应头字段中:

WWW-Authenticate: Digest

这意味着服务器希望客户端使用Digest方法,而不是使用-u时的默认方法Basic
--digest--anyauth添加到命令行。

相关问题