Bootstrap FreeKB - Curl - Basic authentication using the -u or --user option
Curl - Basic authentication using the -u or --user option

Updated:   |  Curl articles

In this example, the foo.html page is being requested from the www.example.com web server.

curl https://www.example.com/foo.html

 

Let's say access to this page require basic authentication (username/password). The -u or --user option can be used to include a username and password in the request.

curl --user john.doe:itsasecret https://www.example.com/foo.html

 


Special Characters

Be aware that if the username or password contains special characters, such as an exclamation point . . . 

curl --user john.doe:itsa!secret https://www.example.com/foo.html

 

Something like this will be returned.

-bash: !s: event not found

 

Special characters will need to be escaped, like like.

curl --user john.doe:itsa\!secret https://www.example.com/foo.html

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 48e27a in the box below so that we can be sure you are a human.