brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl -K – reads options from stdin so a token stays out of ps

Curl
~/tips/tip-curl-config-stdin-token

printf 'header = "Authorization: Bearer %s"\n' "$API_TOKEN" | curl -K - https://api.example.com/me

Passes secrets to curl through stdin instead of visible command-line arguments.

Every argument on a command line can be read by other users through the process list.

printf 'header = "Authorization: Bearer %s"\n' "$API_TOKEN" | curl -K - https://api.example.com/me

-K - makes curl read its options from standard input, one per line in the form option = value. printf is a shell builtin, so the token never shows up in the argument list of a process, while -H "Authorization: Bearer ..." would. Keep the token in an environment variable or a file with mode 600 and do not type it into the command itself, or it lands in the shell history.

Further reading: curl manual

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link