Multiple Curls with User Auth

I want to automate some config file downloads from my repo without using git (just plain set up configurations) and for that I'd like to download those files with curl. As I need user auth for it im curious how I could handle this within one command?

curl --user Linus  -o /home/user/download &&  -o /home/user/forlaterusage

above command does not work as intended.

What I want to achieve is that I only have to enter my password once for multiple downloads.

1 Answer

You can use -u or --user with "user:password" format:

#!/bin/bash
user=Linus
read -sp "Enter Password: " password
curl -u "$user:$password"  -o /path/to/output1
curl -u "$user:$password"  -o /path/to/output2
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest