I always like Ansi escape characters:
echo -e "Enter your password: \x1B[8m" echo -e "\x1B[0m"
8m makes the text invisible, and 0m resets the text to "normal". "-e" makes Ansi possible.
The only caveat is that you can still copy and paste the text you have, so you probably shouldn't use it if you really want to be safe.
It just allows people not to look at your passwords when you enter them. Just don't leave your computer after that. :)
Note:
The above version is platform independent if it supports Ansi escape sequences.
However, for another Unix solution, you can simply tell read not to repeat characters ...
printf "password: " let pass $(read -s) printf "\nhey everyone, the password the user just entered is $pass\n"
dylnmc Sep 21 '14 at 3:29 2014-09-21 03:29
source share