0

i wonder if it is possible to "hide" the password in Linux Shell Script? for example, i have a code here

echo “Enter Password:"
read p
 
if [ $p = “Passwords" ]
then
    echo “Password Granted"
else
    echo "Password Denied"
fi

as you can see when im going to bash it at Linux Terminal, i will be asked to type/enter the password in line 2. in Linux Terminal, whatever you type, the characters are visible. if i type "passwords" or "passhwords" or any character, i can see visibly each character/letter of what i type there.

i wonder if it is possible to "hide" it? similar to Facebook or Google account login where when i type any character it will appear as "*****" instead of the actual characters. is there a code i should enter before "read p"(2nd line) so whatever i will type will be hidden?

OS: Ubuntu

5
  • Are you asking how to encrypt the password after they enter it, or how to hide their typing? Commented Nov 17, 2021 at 16:31
  • ahh i think i used the wrong term. my really bad(i edited the post). im asking how to "hide" the password/text im entering when typing like in Google Account or Facebook login where the password text bot shows "********" when entering characters. Commented Nov 17, 2021 at 16:37
  • see read -s or dialog --passwordbox. Commented Nov 17, 2021 at 16:53
  • Read this answer, section about Some tricks for dedicated tools Commented Nov 17, 2021 at 16:56
  • i see that. i found the answer. thank you! Commented Nov 18, 2021 at 4:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.