PCLinuxOS-Forums
News: ...FLASH!!! ...New PCLinuxOS Testing board now open. Register today! Be an active contributor to the PCLinuxOS future! ... Read all about it now, on THIS forum!!!..
 
*
Welcome, Guest. Please login or register. May 25, 2012, 02:57:15 AM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: [SOLVED]how to show password when entering it?  (Read 230 times)
snork
Full Member
***
Offline Offline

Posts: 97


« on: January 20, 2012, 04:24:22 PM »

When I setup a user on a system, I use 'useradd' and 'passwd'. Using 'passwd' command doesn't show the characters I type, making it tedious to enter long and cryptic passwords for users.

Is there some way to allow me to see what I type in when setting up the password for a new user?

I've tried the old 'echo username:new_pw | chpasswd, which allow me to see what I type, but that command chokes when you use either the '&' or the '!' character in a password, which I believe are allowed special characters.
Logged
AS
Global Moderator
Hero Member
*****
Offline Offline

Posts: 4107

Have a nice ... night!


« Reply #1 on: January 20, 2012, 05:14:33 PM »

When I setup a user on a system, I use 'useradd' and 'passwd'. Using 'passwd' command doesn't show the characters I type, making it tedious to enter long and cryptic passwords for users.

Is there some way to allow me to see what I type in when setting up the password for a new user?

no that I'm aware, hiding the password is considered a feature.

Quote
I've tried the old 'echo username:new_pw | chpasswd, which allow me to see what I type, but that command chokes when you use either the '&' or the '!' character in a password, which I believe are allowed special characters.
The problem here is that the shell is an interpreter, and several characters have special meaning,
if the character where only '&' and '|' the problem could have been solved by "quoting" the strings, like follow:
Quote
echo "username:new_pw" | chpaswd
unfortunately this will chokes when a 'double quote' ( " ) would be used in the password strings, and others characters too.

An alternate method could be to redirect the input to a temp file containing username:password and then using
Quote
chpasswd < tempfile
... provided that you will redirect the "typed in" password without using the shell functions ...
but this will increase the risk, as minimum precaution you should use some secure delete function to overwrite the temp file once the job is done.

Not a very good idea to show out passwords  Roll Eyes

AS


Logged
snork
Full Member
***
Offline Offline

Posts: 97


« Reply #2 on: January 20, 2012, 05:49:11 PM »

Thanks for the responses. That gave me some ideas to try.

Is there some way to use --stdin with that last suggestion (chpasswd < tempfile) instead of creating a tempfile? e.g. chpasswd < user:pw --stdin

I know showing passwords is not a good idea, but when you have to enter 40 users at once and the passwords are 30 characters or more long, with a ton of special characters in them, it's easy to mis-type something, reading the passwords from a piece of paper or email.
Logged
Old-Polack
Administrator
Hero Member
*****
Offline Offline

Posts: 9695


----IOFLU----


« Reply #3 on: January 20, 2012, 06:03:53 PM »

Thanks for the responses. That gave me some ideas to try.

Is there some way to use --stdin with that last suggestion (chpasswd < tempfile) instead of creating a tempfile? e.g. chpasswd < user:pw --stdin

I know showing passwords is not a good idea, but when you have to enter 40 users at once and the passwords are 30 characters or more long, with a ton of special characters in them, it's easy to mis-type something, reading the passwords from a piece of paper or email.

Now you know the reason you get the "big bucks" ... nobody else wants your job...  Grin Grin Grin
Logged

Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...
AS
Global Moderator
Hero Member
*****
Offline Offline

Posts: 4107

Have a nice ... night!


« Reply #4 on: January 20, 2012, 06:23:20 PM »

Thanks for the responses. That gave me some ideas to try.

Is there some way to use --stdin with that last suggestion (chpasswd < tempfile) instead of creating a tempfile? e.g. chpasswd < user:pw --stdin

I know showing passwords is not a good idea, but when you have to enter 40 users at once and the passwords are 30 characters or more long, with a ton of special characters in them, it's easy to mis-type something, reading the passwords from a piece of paper or email.

Quote
read  -p  "username: "  X  ;  read  -p  "password: "  Y  ;  echo  "$X:$Y"  |  chpasswd

or, if running directly from a logged user:
Quote
read  -p  "password: "  Y  ;  echo  "$LOGNAME:$Y"  |  chpasswd

 Wink
Logged
snork
Full Member
***
Offline Offline

Posts: 97


« Reply #5 on: January 20, 2012, 07:00:56 PM »

Old-Polack, If I'm getting the big bucks, they must be sending them to the wrong address. Wink

AS, Those suggestions look very interesting. I'll have to try them the next time I have to create new users.

Thanks a lot.

I'm going to mark this as solved since those look like they will work.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM