Grabbing a protected webpage from the command line

Ever needed to grab a password protected page from the command line? This can be accomplished with curl’s “-u” option:

$ curl -k -i https://prefetch.net/secret -u me:somethingstrong |more

The username and password can be passed as an argument to the “-u” option. If you are paranoid about your password being visible on the command line, you can omit the password, and curl will prompt you for it:

$ curl -k -i https://prefetch.net/secret -u me
password:

In case you are curious, the “-k” option forces curl to dump the HTTP headers. I use both options to debug web server issues.

1 thought on “Grabbing a protected webpage from the command line”

Leave a Reply

Your email address will not be published. Required fields are marked *