no crypt
dear members,
iam missing the crypt-command in my slackware 10.2. iam a newbee @linux and want to add a sytem-user using a servlet. i need one command-line to add a user and set the encryptet pw. can anyone help me ? greez |
you want to add a user in one command ? hehe try man useradd.
it will probably be something like useradd -d /home/username -s /bin/bash -p password username |
>> useradd -d /home/username -s /bin/bash -p password username
ofcourse...but in this case i must give the password crypted. so i need a script or a single commandline witch crypt the pw and give it to the useradd command. |
I searched for that some days ago, but although I have a strong hint I could not get it working - the computed output and the entry in /etc/shadow (generated from "passwd") still differ. openssl might be able to do this: http://www.linuxjournal.com/node/8958/print
|
Give it some salt and the meal is ready :)
http://www.madboa.com/geek/openssl/#passwd-md5 |
Perhaps you mean something like this?
This program, cvspas, is used to generate the password entry for CVS; it prompts for the password and prints the login name of the person running the program along with the encrypted password. The output is, for example, Code:
# cvspas Code:
cc -O3 -s -o cvspas cvspas.c -lcrypt Code:
#include <stdio.h> See the manual pages for the functions the program calls if you want more information. |
thanks for the script!
i tryed the openssl and it seams to work fine. now my next question: how can i combinate the openssl command with the useradd command in ONE line to generate a new user with encrypted password ? many thanks... |
It's not exactly a one-liner, although you can of course append the lines with ";". And it's not the best method I guess.
I export first some variables, a better choice I guess would to put the lines in a bash script and use parameters $1 $2 and $3 instead of the static export lines. Code:
export SET_USER=username Code:
export ENC_PASSWD=$(openssl passwd -1 -salt 3gZekj8m mypassword) ; useradd -g users -G video,cdrom,floppy -m -p "$ENC_PASSWD" -s /bin/bash username ; unset ENC_PASSWD Code:
useradd -g users -G video,cdrom,floppy -m -p "$(openssl passwd -1 -salt 3gZekj8m mypassword)" -s /bin/bash username |
All times are GMT -5. The time now is 10:13 PM. |