When I want to ask for a password in a bash
script, I do that :
read -s
…but when I run bash
in POSIX mode, with sh
, the -s
option is rejected:
$ read -s
sh: 1: read: Illegal option -s
How do I securely ask for an input with a POSIX-compliant command ?
Best Answer
Note that for those shells (mksh) where
printf
is not builtin, the password will appear in clear in theps
output (for a few microseconds) or may show up in some audit logs if all command invocations with their parameters are audited.