I can't make 'useradd' work
Code:
useradd -u 8001 -g luc -p mypassword -s /usr/bin/bash -d /home/luc luc Code:
luc[159-0]test> ssh luc@61.62.63.64 # userdel luc # adduser (answer all the questions...) Jump back to the other terminal... Try SSH login... Success! 'adduser' works, 'useradd' doesn't. Why? I have read the man pages several times and can't find the error in my command line. I have a similar problem with groupadd This fails: groupadd -g 8001 staff This works: groupadd staff why?! TIA |
-p takes an encrypted password, not a plaintext passwd. It needs to be the exact md5 / sha hash that goes into /etc/shadow.
|
Do you know how I can obtain that hash? I really wish I could automate this entire procedure...
'man useradd' says that -p specifies "the encrypted password, as returned by crypt(3)." There is no 'crypt' command or package, neither on Ubuntu nor on Slackware. I assume some other package or library provides that command, but the man page won't say what it is. That would be too helpful for a man page, which must be against the rules or something. ;) |
Quote:
You can also do... Code:
root@host# echo "password" ¦ md5sum |
Well, I'm trying to get by on my own but haven't made much progress. To wit:
- I created the account with adduser, which works, then I checked what the encrypted password is in /etc/shadow. Then I ran echo "password" ¦ md5sum like you suggested. In fact, I tried that long before I got your reply. The output of that command does not match the encrypted password in /etc/shadow. I didn't try just md5sum, I also tried it with shasum, sha1sum, and all the other sha[1-9]*sum commands I have here, for good measure. None of those output the same encrypted password I have in /etc/shadow. - I downloaded the mcrypt package, so now I have the mcrypt command. But I can't figure out how to use it to obtain the same encrypted password I can use in /etc/shadow. Mcrypt, in good Linux tradition, makes the whole task at hand a lot more difficult than it could have been. It refuses to output to the terminal so I can see the darn output and compare with the encrypted password I already have. So I redirect it to a file, which turns out to be binary and gets all garbled with 'cat'. Can someone please enlighten me? This is getting really tiresome. I just want to use one damn option in one damn command, I am sick of going through all this trouble because of one line in my 80-line script. TIA |
I'm not sure about getting the crypt() result of a password but how about a workaround. Just create your user without supplying the password then add a line to the script to change the password like this :
Code:
useradd -u 8001 -g luc -s /usr/bin/bash -d /home/luc luc |
Quote:
Code:
echo "password" ¦ passwd --stdin username |
Quote:
|
Quote:
Code:
#!/usr/bin/python Code:
useradd -u 8001 -g luc -p $(./tpwd.py mypassword) -s /usr/bin/bash -d /home/luc luc |
well you can use the chpasswd tool to do this seperately, which does take in a plain text password. You can also feed chpasswd a single file / stdin stream of user:password lines and it'll do them all in one go.
|
All times are GMT -5. The time now is 03:30 PM. |