I'm writing a script in Bash that prompts the user for a password and I need the typed text to not show, as when you enter an ssh password.
Does anyone have the solution for this?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
In order for the terminal not to show typed text,
echo needs to be turned off. The command
stty -echo does this. To return to normal, run
#!/bin/sh printf "Enter password: " stty -echo read -r password stty echo echo "" echo "password=$password"
If, due to a typo or other error, the script fails to restore echo, run
reset to recover.