Is it possible to make the password visible as asterisks (or any other character) on using sudo command?

Currently, it does not display anything, thus making it difficult to count the number of keystrokes pressed..


Open your terminal and edit /etc/sudoers.tmp file with:

sudo visudo

Modify the following line:

Defaults env_reset


Defaults env_reset,pwfeedback

Save and exit. Restart your terminal and now, when you run a command with sudo, you should get visual feedback when you type in your password.

Credit goes to: Make Password Asterisks Visible in Your Mac or Linux Terminal

| improve this answer | |

While there is no configuration nor parameter option to do that directly with in the terminal sudo, you could theoretically accomplish something similar to what you need.

First you will need to set the environment variable

export SUDO_ASKPASS=/usr/bin/ssh-askpass

Then you would run your command with -A option, for example

sudo -A ls

This will give you a graphical prompt.

In theory you could write your own programme rather than using ssh-askpath, your code needs to display the prompt as it is given in the argv[1], read user's password (displaying stars, circles, or anything else you fancy), and then display it to stdout. Do not worry about displaying it, since sudo will not allow this password to ever be seen, it will intercept such display.

| improve this answer | |
  • Oh, i guess i was wrong, there is a way to do stars directly, as pointed by rajagenupula, i stand corrected. – v010dya Dec 8 '13 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.