3 ms·
add two spaces right before the echo to avoid logging your secrets in the shell history
by sambazi 3y ago
add two spaces right before the echo to avoid logging your secrets in the shell history
- andrewla 3y agoOr better, just do a `(read -s asdf; echo -n $asdf | shasum)` to create a temporary subshell and never even expose your password in the shell output.
- sambazi 3y agowill create interesting errors with certain characters
- mzs 3y ago% head -1 | tr -d \\n | shasum Type your username and press the RETURN key.
- codetrotter 3y agoOne space is sufficient in bash, if memory serves right. And secondly, on macOS with the default config for zsh no amount of spaces will help, I think. You have to first configure zsh to ignore from history when starting with space. And after that I think one space will be enough.
- nijave 3y agoThat functionality in bash is controlled by the HISTCONTROL environment variable. Many systems this defaults to "ignorespace" but this isn't always the case. On Fedora, with bash, HISTCONTROL defaults to "ignoredups" and is set by /etc/profile (unless it's changed in the last few years). Usually you can set/unset the shell option "history". For instance, "set +o history" to disable history in the current shell and "set -o history" to turn it back on. Edit, Looks like on Ubuntu HISTCONTROL=ignoreboth comes from .bashrc in /etc/skel/
- sambazi 3y agothanks for the context