SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
mcrypt is the Linux version of crypt ...
You can also do...
Code:
root@host# echo "password" ¦ md5sum
To get the hash...there is also a sha1sum command as well
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.
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
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 :
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
instead of trying to pass the -p to the useradd command...why don't you add one more line to your 80 line script?
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
"man 3 crypt" tells you how the password is generated. It isn't an md5 hash of the input string.
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810
Rep:
Quote:
Do you know how I can obtain that hash? I really wish I could automate this entire procedure...
I have been looking into the crypt function and have made a little python script that takes the password as a command line argument and returns the encrypted password. Here it is:-
If you create a script file with this, for example tpwd.py, and make it executable you may run your original one liner to add a user, (from the directory tpwd.py is in), like this :
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.