LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-18-2013, 11:18 AM   #1
linx444
LQ Newbie
 
Registered: Mar 2006
Posts: 21

Rep: Reputation: 1
Question useradd (-p) is not encrypting /etc/shadow


Hi

I am adding a user to my linux server but when I do the password is not using crypt to encrypt password for /etc/shadow. Instead it adds it in as clear text. I have looked at the login.defs, not sure why useradd is not encrypting password :/ any pointers would be appreciated.

# Use SHA512 to encrypt password.
ENCRYPT_METHOD SHA512

MD5_CRYPT_ENAB no

Linx444
 
Old 03-18-2013, 07:40 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Using '-p' expects the encrypted password not plaintext .. if you're doing this in a script try:

Code:
useradd <user>
echo '<password>' | passwd --stdin <user>
 
Old 03-19-2013, 05:55 AM   #3
linx444
LQ Newbie
 
Registered: Mar 2006
Posts: 21

Original Poster
Rep: Reputation: 1
Hi kbp

Many thanks for the update and help. For some strange reason I was under the impression that it also encrypted the password. Ok cool, will try the above in the script with the variable.

Linx444
 
Old 03-19-2013, 08:35 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Actually, the man page does specify encrypted
Quote:
-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the password.

Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes.
Note the warning there ... which also applies to the --stdin method...

For bulk creation consider http://linux.die.net/man/8/newusers
 
Old 03-20-2013, 11:10 AM   #5
linx444
LQ Newbie
 
Registered: Mar 2006
Posts: 21

Original Poster
Rep: Reputation: 1
I thought it usually did, I wander what setting has changed for this part to be disabled! Puzzling !
 
Old 03-20-2013, 07:53 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you mean useradd, its always been that way; lots of people get caught by it
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
useradd command to create passwd, shadow & other files under different directory rramesh1 Linux - Newbie 2 05-20-2011 07:26 AM
Useradd - Cannot locate /etc/default/useradd in Solaris Paean Solaris / OpenSolaris 4 12-09-2005 01:36 AM
useradd not found, but shadow is installed Ziax Fedora 2 10-16-2005 05:37 AM
useradd without shadow password twallstr Linux - Software 1 09-08-2005 02:14 PM
/etc/shadow and useradd -p usermod -p granny Linux - Security 3 08-29-2003 12:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration