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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-29-2010 #1
- Join Date
- Jul 2010
Creating user + password directly
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...
- 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:
useradd newuser && passwd newuser
- 07-29-2010 #3
- Join Date
- Jul 2008
assign the user a null password
# usermod -p "" newuser
make the password expire immediately
# chage -d 0 newuser
- 07-30-2010 #4
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 #5
- Join Date
- May 2009
useradd -p$(perl -e 'print crypt($ARGV, "saltrandom")' "password") user
I've used this-^
In theory this should work but havent tried -\
usermod-p$(perl -e 'print crypt($ARGV, "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