adding users and passwords with adduser
I'm trying to create a new user with a password via script file and I'm using the -p option for the password but, I need to give it the crypted password as returned by crypt() function. This is what is says in the man pages for adduser.
The problem is in my script the crypt command is not found. Therefore I cannot create a crypted password. Help please! This is in RHEL 4. |
Hi,
crypt() is not a function that you can use in bash, it is a c(++) function. If you want to use it you need to write a little c (or c++) script around it. After compiling you'll end up with a binary that can produce the encrypted password needed by useradd's -p option. This rough example creates md5 encrypted passwords: Code:
#define _XOPEN_SOURCE An example run: Code:
$ ./md5.crypt FooBar |
You could use the makepasswd program (you will probably need to install it first):
Code:
echo "mypassword" | makepasswd --clearfrom=- --crypt-md5 |awk '{ print $2 }' |
Quote:
useradd -g addm -d /home/bbd -m -c "ADDM user" -p '$1$$obKSzVJoc/mJ1ozCv.5/z.' -s /bin/bash bbd |
All times are GMT -5. The time now is 09:28 PM. |