Linux wget and http authentication

wget authentication

We covered how to enable http authentication in nginx web server in a previous article https://vpsie.com/nginx-http-authentication-on-your-linux-vps/. As a result, we also need to cover how to fetch web objects with wget when the objects require http basic authentication.

HTTP Basic authentication allows to protect web locations or subdomains with a basic user/password authentication schema.

Wget is the tool to download http/https pages or objects from your Linux VPS CLI and, fortunately, it can fetch these resources even if they protected with http basic auth. For resources protected with session/cookie systems, it is more complex.

Wget files from http authentication websites

$ wget --http-user=[HTTP-USER] --http-passwd=[HTTP-PASSWORD] https://server1.domain.com/vault/file.xml

Since the username and password used by wget to perform the http authentication are used in a CLI, they will remain in your shell’s history. Make sure you clear these lines by logging out and logging back in and editing the history file. For bash, it is .bash_history in your root directory.

 

You can actually create these settings on our platform in few minutes utilizing our PCS (Private Cloud Solution) which allows you to have VPSie(s) on a private network – NAT – Port forward – traffic control for inbound and outbound – multiple gateway IPs which you could use for the load-balancing and failover.

Related Articles