Results 1 to 6 of 6
Hey guys,
I have a couple of questions for CENTOS 5.5FINAL x86_64 os..
I need a command that will create a user + password directly(will be used in php..)
like ...
- 07-29-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 7
Creating user + password directly
Hey guys,
I have a couple of questions for CENTOS 5.5FINAL x86_64 os..
I need a command that will create a user + password directly(will be used in php..)
like useradd wtest -p 123456 (should work in the useradd help, but for some reason doesnt, maybe need the encrypted part of 123456?)
and another that will change a user directly like password wtest 123456
and not via passwd, because i dont think it can be used in php...
Thanks,
gal.
- 07-29-2010 #2
If your goal is to include the new password inside the passwd command this will not be possible. They do this for security reasons. Using the passwd command requires user input after the command has been typed. You can run the useradd and passwd command in a single command though such as:
but still using the above command will still require user input for the actual password change.Code:useradd newuser && passwd newuser
- 07-29-2010 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
assign the user a null password
# usermod -p "" newuser
make the password expire immediately
# chage -d 0 newuser
- 07-30-2010 #4Just Joined!
- Join Date
- Apr 2010
- Posts
- 69
You could update the system user database directly (/etc/passwd) or use the chpasswd command (available on CentOS 5.5, see "man chpasswd").
If updating the db directly, you would probably also want to mimic the behavior of useradd in other ways, like the copying of /etc/skel for home directories. You would also need to encrypt the password beforehand using crypt, openssl, or grub-md5-crypt.
If you use chpasswd, you have the option to supply passwords in plaintext or encrypted depending on the options you pass.
- 07-31-2010 #5Just Joined!
- Join Date
- May 2009
- Posts
- 4
useradd -p$(perl -e 'print crypt($ARGV[0], "saltrandom")' "password") user
I've used this-^
In theory this should work but havent tried -\
usermod-p$(perl -e 'print crypt($ARGV[0], "saltxyyzzy")' "password") me
Edit to mention - 1 reason clear text passwords arent used directly in a command line are in theory it could be captured in a process listing.
- 07-31-2010 #6
useradd -c "Local User" -m -s /bin/bash user01 && echo "user01:my_pass" | chpasswd


Reply With Quote