Hiding your password when typed as an argument into a bash shell / command prompt?

leeand00

enter image description hereI was using weechat when I noticed that if I do a command in the program like /msg IdentServ identify <my-password> that it actually blanks out your password as you're typing it...see image below:

However...when I use a program in Linux or Windows that requires that you type your password in the Terminal, Cmd.exe or Powershell, passing it usually as a command line argument, it just leaves it out there for everyone looking over your shoulder to see.

Is there a feature like this in Windows or Linux? Is it also possible to do this when pressing the up-key prior to a timeout after which it no longer operates in this manner to re-run the same command again?

I'm aware of things like sudo and ssh keys for linux, which does kind of solve the problem, but not really aware of anything but Powershell "secure strings" for Windows.

C0deDaedalus

I don't get much to know, by the details you provided, however I assume the question title itself makes all of it and will answer that :

Hiding your password when typed as an argument into a bash shell / command prompt ?

Being a linux user, I would answer it for bash shell. You can write a shell script that prompts for password like this.

#!/bin/bash
echo -n Password:    # Prompt for entering password 
read -s password     # read password by suppressing it using -s option
echo
echo $password       # print password

Here -s in read command means suppress that suppress the output stream to show anything. Thus having your password invisible when you type it.

NOTE : It works in a shell script, but to make it work in applications such as weechat, you have to change the underlying code or better write a shell script that does it when you open the app for the first time.

To read more on this topic follow this and this

Feel free to add-in more details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I accidentally typed password into bash command line

VIM, when I shell to prompt using :!bash I'd like the command prompt to reflect me being in a shell

How can a shell output affect the typed text after the command prompt?

Hiding Password in Shell Scripts

Pipe password argument to mount shell command

Bash shell (Ubuntu) on the command prompt (Windows 8)

Passing argument to command in bash shell script

How to shorten your command line prompt (bash) like Spatry does it?

Bash Script - Automatic fill the given password when prompt for password

Hiding password field in command line

No password prompt at sudo command

Hiding Command Messages in a Shell Script

Running a bash command in Python, when said bash command requires a password?

SSH makes all typed passwords visible when command is provided as an argument to the SSH command

Shell install script moves command prompt to the right when done

Bash - Hiding a command but not its output

Configure bash to execute command with last argument when no argument was provided

Start msys mingw32 shell with bash command as argument

Missing a prompt of read command when using pipe in Bash?

bash array working in command prompt but not working when executing as ksh

Can a bash script prepopulate the prompt with a command to run when it exits?

Hiding plain text password with sqlplus command line

Bash Command as Bash Command Argument

Are the terms 'shell prompt' and 'command prompt' interchangeable?

I/O error when passing command line argument to a shell script

Command Prompt - Shell, Terminal, Console?

Customize the command shell default prompt

Gnome Shell command prompt history

what is bash command `command` used for and what is it when it appears in shell script