add a user with password without prompt
Hi,
I want to add a user with its password without the need to prompt data like the password. I've tried with this command: useradd prometeo -d /home/prometeo -g test -m -p pippo but the -p option ask for a password generated in the crypt-way. So I've tried passing the output of /usr/bin/mkpasswd pippo to useradd prometeo -d /home/prometeo -g test -m -p using a pipe and < but I can't find a way to make it work! Is it possible or does I need to use a script? Someone have some suggestions? Thanks |
Check the --stdin option for useradd.
Man useradd |
Ok....This will do what you want and as suggested by iceman47....
----------------------------------------------------------------------------- useradd dog; echo "your-password" | passwd dog --stdin ----------------------------------------------------------------------------- The password will be changed without prompting. Regards, amit |
I've checked in the useradd man page but there is no --stdin. I'm using debian sid.
I've tried the command suggested, the user is added but passwd give an error: passwd: opzione non valida -- - usage: passwd [-f|-s] [name] passwd [-x max] [-n min] [-w warn] [-i inact] name passwd {-l|-u|-d|-S|-e} name first line tells: the option -- - is not valid |
I've got the command:
useradd prometeo -d /home/prometeo -g test -m -p `mkpasswd pippo` it works, no prompt, password is the word after mkpasswd :-) thanks |
setting passwords in a script in Debian
Thanks! That's nice for a new user's password.
But How do I use a script to *reset* an existing user's password to something given? |
'usermod' is used to change exisintg user's settings. It works just like 'useradd'.
regards, ...drkstr **edit** I'm not sure if your asking for help with the command, or the script. If the later, $1 is used to access a command line parameter in a shell script, $2 for the s2nd parameter ...etc. see http://tldp.org/LDP/abs/html/ for all the available options to parse command line parameters **edit again** type: 'useradd' not 'user add'. My bad ;) |
Solution good
Perfect! Thanks, usermod has the -p too ...
c |
All times are GMT -5. The time now is 04:39 PM. |