LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-12-2004, 07:24 AM   #1
grendel-IT
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian,Gentoo,Ubuntu
Posts: 23

Rep: Reputation: 15
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
 
Old 03-12-2004, 09:35 AM   #2
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
Check the --stdin option for useradd.
Man useradd
 
Old 03-12-2004, 10:19 AM   #3
coolamit78
Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: RHEL AS 3/4, Windows XP
Posts: 546

Rep: Reputation: 31
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
 
Old 03-13-2004, 07:49 AM   #4
grendel-IT
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian,Gentoo,Ubuntu
Posts: 23

Original Poster
Rep: Reputation: 15
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
 
Old 03-13-2004, 07:58 AM   #5
grendel-IT
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian,Gentoo,Ubuntu
Posts: 23

Original Poster
Rep: Reputation: 15
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
 
Old 09-27-2006, 01:01 PM   #6
cpbl
LQ Newbie
 
Registered: May 2004
Location: vancouver, canada
Distribution: latest ubuntu
Posts: 28

Rep: Reputation: 15
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?
 
Old 09-27-2006, 01:11 PM   #7
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
'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

Last edited by drkstr; 09-27-2006 at 02:23 PM.
 
Old 09-27-2006, 02:07 PM   #8
cpbl
LQ Newbie
 
Registered: May 2004
Location: vancouver, canada
Distribution: latest ubuntu
Posts: 28

Rep: Reputation: 15
Solution good

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add an user, without password?? cenzole Linux - Newbie 21 08-07-2013 05:58 PM
PAM: user{add,del} asks for password systemparadox Linux - Security 1 11-19-2005 03:59 PM
Help! Cannot Add a User to User Manager or Change Root Password lennysokol Linux - General 2 06-25-2005 09:59 AM
add user prompt for password on login redir Linux - Newbie 2 02-28-2005 11:01 AM
Samba 3.0: net user add - problem with password geodo Linux - Networking 1 12-06-2004 11:52 AM


All times are GMT -5. The time now is 02:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration