LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   add a user with password without prompt (https://www.linuxquestions.org/questions/linux-software-2/add-a-user-with-password-without-prompt-156676/)

grendel-IT 03-12-2004 07:24 AM

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

iceman47 03-12-2004 09:35 AM

Check the --stdin option for useradd.
Man useradd

coolamit78 03-12-2004 10:19 AM

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

grendel-IT 03-13-2004 07:49 AM

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

grendel-IT 03-13-2004 07:58 AM

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

cpbl 09-27-2006 01:01 PM

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?

drkstr 09-27-2006 01:11 PM

'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 ;)

cpbl 09-27-2006 02:07 PM

Solution good
 
Perfect! Thanks, usermod has the -p too ...
c


All times are GMT -5. The time now is 04:39 PM.