Home > Net >  Curl responded with 401: Unauthorized even with username and password sent
Curl responded with 401: Unauthorized even with username and password sent

Time:09-09

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:[email protected]/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:[email protected]/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:[email protected]/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

CodePudding user response:

The clue is in this response header field:

WWW-Authenticate: Digest

It means the server wants the client to use the Digest method, and not Basic which is the default method when -u is used.

Add --digest to the command line, or perhaps --anyauth.

  • Related