LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-20-2011, 12:43 AM   #1
rosect
LQ Newbie
 
Registered: Oct 2011
Posts: 19

Rep: Reputation: Disabled
Problem with command useradd


I tried to use the command "useradd" to create an account. The complete command is:

useradd -p "$1$0up/D4zT$79ysvovohtDSgTRy7kLUr0" -s ~root/wcp/cli aaa

where "aaa" is the user name.

However, when I look at the /etc/shadow file, I see this:

aaa:-bashup/D4zT9ysvovohtDSgTRy7kLUr0:15328:0:1:1:::

The encrypted password is not what I gave in the command.

Can someone let me know why this happens? My OS is "2.6.35.6-45.fc14.i686"

(For certain reason, I do not want separate the command into "useradd" and "passwd". )

Thank you.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-20-2011, 09:10 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
When you use the useradd command, supplying the password for it is in original text; It will be encrypted and added to /etc/shadow. You need to supply the actual password the user will be using, and not the encrypted hash.

Cheers,

Josh
 
Old 12-20-2011, 11:26 AM   #3
rosect
LQ Newbie
 
Registered: Oct 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Hi, Josh, Thank you for your reply.

With option "-p" in command useradd, you need to pass in encrypted password. If you use command passwd, then you may use plain text. Linux man page of useradd clearly says so.

I did try with plaintext as password with the command. In the /etc/shadow, the plaintext password is used as-is, not encrypted.
 
Old 12-20-2011, 11:41 AM   #4
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
Try using single quotes rather than the double ones. I think what's happening is that the shell is trying to interpret $0 $1, and $7. It didn't find $1 and $7, and so leaves them out. It did find $0, the value of which is "bash".
Or you could try something without $ and /.
 
2 members found this post helpful.
Old 12-20-2011, 11:52 AM   #5
rosect
LQ Newbie
 
Registered: Oct 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Hi, impert,

Your suggestion worked. Thank you. And let me summarize how we should do.

1. If you pass in encrypted password without quotation marks, as impert pointed out, the '$' is not interpreted correctly.

2. If you pass in with (double) quotation mark, it is the same as above.

3. impert is correct. Pass in the encrypted password with SINGLE quotation mark. And that works!

Thank you, impert!
 
Old 12-21-2011, 06:13 AM   #6
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
You're welcome.
Actually, I learned something too. I've been using useradd for years without ever realising that there was the option to set the password with it.
 
Old 12-21-2011, 10:27 AM   #7
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Oops, I was thinking of something else. Sorry about that!
 
  


Reply

Tags
password, security, system



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with useradd/userdel command on RHEL5 smsahmed Linux - General 9 07-04-2010 02:11 AM
useradd command problem rohit_67066 Linux - Server 2 02-25-2008 10:21 AM
useradd command Linuxien Linux - General 2 11-14-2006 07:32 AM
useradd command johnpayback Linux - General 4 08-13-2002 05:24 PM
useradd command allancondino Linux - General 5 04-27-2002 12:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:58 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