#!/bin/bash
# Prompt user for username and password
read -p "please enter username and press [enter]: " username
echo -n "please enter password and press [enter]: "
# Save current terminal settings
oldstty=$(stty -g)
# Disable canonical mode and local echo
stty -icanon -echo
# Get the first keystroke using dd
key=$(dd bs=1 count=1 2>/dev/null)
# While key is not "Enter" store key in the password,
# echo an asterisk and get another keystroke
while [ x$key != x$(echo) ]
do
password=$password$key
echo -n \*
key=$(dd bs=1 count=1 2>/dev/null)
done
echo
# Restore old terminal settings
stty "$oldstty"
# Check results
echo $username
echo $password
Blank out the Password in Python would be.
#!/usr/local/bin/python
import getpass
user = raw_input('Enter your user name ')
passwd = getpass.getpass('enter your password ')
print user
print passwd
raw_input('Press ENTER to exit')