Joined August 2017
·
Posted to
Securely use basic auth with curl
over 1 year
ago
Thank you for these tips!
The reason the example with cat is not working as it is, is that cat prints out a newline from the file.
By removing the newline, the code will work:
{ echo -n 'user = "'; cat password.txt | tr -d '\n'; echo '"'; }
tr -d '\n' deletes the newline from the (end of the) data.
After a careful read of man curl, it appears that this might actually be the best way:
curl -K curlconfig.cfg http://www.googles
Then you insert this line to curlconfig.cfg (or what ever filename you like):
user = "defn:password"
Works like a charm. Also, you can add other curl options to that file as well as separate lines.