Shell输入密码时关闭屏幕回显

820阅读 0评论2016-01-25 sync_1521
分类:LINUX

Shell输入密码时关闭屏幕回显
在实际应用中,一般当我们在键盘上键入口令时不希望将其显示在屏幕上,
为此可采用下面的两种办法:
1.使用stty 命令 
stty -echo # do not display password 
echo "Enter password: \c" 
read PASSWD #get the password
stty echo # restore standard configuration
 
2.使用echo命令
设置保密属性:echo "\033[8m"
取消保密属性:echo "\033[m"

3.read -s 不显示终端的任何输入

上一篇:ssh黄金参数
下一篇:批量实现无密码认证脚本