Hashing out typed passwords

96 views
Skip to first unread message

Ray

unread,
Oct 30, 2006, 3:48:37 PM10/30/06
to bash tips
Hi all.

Very new to Bash scripting well infact any scripting. So i hope that
you maybe able to help me out here.


I have a script that asks for a password to be entered so it can be
used later on in the script. This works great execpt tyat you can see
the password in plain text when you have enterd it on screen. What i
would really like it to do is to echo ****** as i type the password.
That way nobody should be able to scroll up the screen buffer to get
the password.


Is it possible? if so how


Cheers

Maxim Vexler

unread,
Nov 3, 2006, 9:08:07 AM11/3/06
to bash...@googlegroups.com

Hi Ray,

You can always use stty to switch off echo, see:
<<<<<
#!/bin/sh
read -p "Username: " uname
stty -echo
read -p "Password: " passw; echo
stty echo
>>>>> (Source [1])

Please note that this still doesn't provide the same security level as
login (as an example of a secure input does) this is because other
users on your system could be running "ps -ef" where the input from
the second read could be visible.

HTH

[1] http://www.peterbe.com/plog/passwords-with-bash

--
Cheers,
Maxim Vexler

"Free as in Freedom" - Do u GNU ?

Reply all
Reply to author
Forward
0 new messages