curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

curl cannot authenticate with router using basic http authentication

From: Bruno Dantas via curl-users <curl-users_at_cool.haxx.se>
Date: Thu, 11 Jul 2019 07:23:37 -0400

I have a script that runs in my router every so often to reboot my modem.

The script works with wget, but I would like to implement it with curl
because this script is the only reason I have wget installed.

The trouble is that while wget can authenticate with the modem, curl
cannot. Here is the output of the relevant commands:

--------------------

bruno_at_box:/opt$ wget -O /dev/null
http://admin:password@192.168.100.1/RouterStatus.htm
--2019-07-10 13:48:56--
http://admin:*password*@192.168.100.1/RouterStatus.htm
Connecting to 192.168.100.1:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authentication selected: Basic realm="NETGEAR CM400"
Connecting to 192.168.100.1:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50638 (49K) [text/html]
Saving to: '/dev/null'

/dev/null 100%[===================>] 49.45K --.-KB/s in
0.009s

2019-07-10 13:48:56 (5.24 MB/s) - '/dev/null' saved [50638/50638]

bruno@box:/opt$ curl http://admin:password@192.168.100.1/RouterStatus.htm
<HTML>
<HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
</HTML><HR>
Error: 401 Unauthorized</TITLE></HEAD>

bruno@box:/opt$ curl --verbose http://admin:password@192.168.100.1/RouterStatus.
htm
* Trying 192.168.100.1...
* TCP_NODELAY set
* Connected to 192.168.100.1 (192.168.100.1) port 80 (#0)
* Server auth using Basic with user 'admin'
> GET /RouterStatus.htm HTTP/1.1
> Host: 192.168.100.1
> Authorization: Basic YWRtaW46cGFzc3dvcmQ=
> User-Agent: curl/7.54.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="NETGEAR CM400"
< Server: NET-DK/1.0
< Date: Thu, 11 Jul 2019 06:20:20 GMT
< Set-Cookie: XSRF_TOKEN=2830035633; Path=/
< Content-Type: text/html
< Connection: close
< Pragma: no-cache
<
<HTML>
<HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
</HTML><HR>
Error: 401 Unauthorized</TITLE></HEAD>
* Closing connection 0

bruno@box:/opt$ curl -I http://192.168.100.1
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="NETGEAR CM400"
Server: NET-DK/1.0
Date: Wed, 10 Jul 2019 12:54:58 GMT
Set-Cookie: XSRF_TOKEN=3273351995; Path=/
Content-Type: text/html
Connection: close
Pragma: no-cache

--------------------

I tried other authentication methods (e.g., --digest) without luck, which
is not surprising (the modem reports it uses Basic http authentication).
Any ideas how to make the authentication succeed?

Thank you,
Bruno "GNUser" Dantas

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-07-11