Home > Linux > How to hide password entry using stty

How to hide password entry using stty

This scripts allow the user to type the password without it be shown in the screen.

Copy and past the content bellow  in a .sh file

#!/bin/bash 

echo -n "Password: "
stty -echo
read PASSWD
stty echo
echo -e "\nYour password is:" $PASSWD

Running the shell script

# ./hiddenpasswd.sh
Password:
Your password is: t$prod123%f
Advertisement
Categories: Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.